libMesh::OldSolutionValue< Output, point_output > Class Template Reference

#include <generic_projector.h>

Inheritance diagram for libMesh::OldSolutionValue< Output, point_output >:

Public Member Functions

 OldSolutionValue (const libMesh::System &sys_in, const NumericVector< Number > &old_sol)
 
 OldSolutionValue (const OldSolutionValue &in)
 
Output eval_at_node (const FEMContext &c, unsigned int i, unsigned int elem_dim, const Node &n, Real=0.)
 
Output eval_at_point (const FEMContext &c, unsigned int i, const Point &p, Real=0.)
 
void eval_old_dofs (const FEMContext &c, unsigned int var, std::vector< Output > &values)
 
template<>
Number eval_at_node (const FEMContext &c, unsigned int i, unsigned int, const Node &n, Real)
 
template<>
Gradient eval_at_node (const FEMContext &c, unsigned int i, unsigned int elem_dim, const Node &n, Real)
 
template<>
void get_shape_outputs (FEBase &fe)
 
template<>
void get_shape_outputs (FEBase &fe)
 
template<>
void get_shape_outputs (FEBase &fe)
 
template<>
void get_shape_outputs (FEBase &fe)
 
void init_context (FEMContext &c)
 
bool is_grid_projection ()
 

Static Public Member Functions

static void get_shape_outputs (FEBase &fe)
 

Protected Member Functions

template<>
const Real out_of_elem_tol
 
template<>
const Real out_of_elem_tol
 
template<>
const Real out_of_elem_tol
 
template<>
const Real out_of_elem_tol
 
void check_old_context (const FEMContext &c)
 
bool check_old_context (const FEMContext &c, const Point &p)
 

Protected Attributes

const Elemlast_elem
 
const Systemsys
 
FEMContext old_context
 

Static Protected Attributes

static const Real out_of_elem_tol
 

Private Attributes

const NumericVector< Number > & old_solution
 

Detailed Description

template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
class libMesh::OldSolutionValue< Output, point_output >

The OldSolutionValue input functor class can be used with GenericProjector to read values from a solution on a just-refined-and-coarsened mesh.

Author
Roy H. Stogner
Date
2016

Definition at line 373 of file generic_projector.h.

Constructor & Destructor Documentation

template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
libMesh::OldSolutionValue< Output, point_output >::OldSolutionValue ( const libMesh::System sys_in,
const NumericVector< Number > &  old_sol 
)
inline

Definition at line 376 of file generic_projector.h.

References libMesh::FEMContext::OLD.

377  :
378  OldSolutionBase<Output, point_output>(sys_in),
379  old_solution(old_sol)
380  {
383  }
const NumericVector< Number > & old_solution
void set_algebraic_type(const AlgebraicType atype)
Definition: fem_context.h:948
void set_custom_solution(const NumericVector< Number > *custom_sol)
Definition: fem_context.h:963
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
libMesh::OldSolutionValue< Output, point_output >::OldSolutionValue ( const OldSolutionValue< Output, point_output > &  in)
inline

Definition at line 385 of file generic_projector.h.

References libMesh::FEMContext::OLD, and libMesh::Real.

385  :
386  OldSolutionBase<Output, point_output>(in.sys),
387  old_solution(in.old_solution)
388  {
391  }
const NumericVector< Number > & old_solution
void set_algebraic_type(const AlgebraicType atype)
Definition: fem_context.h:948
void set_custom_solution(const NumericVector< Number > *custom_sol)
Definition: fem_context.h:963

Member Function Documentation

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionBase< Output, point_output >::check_old_context ( const FEMContext c)
inlineprotectedinherited

Definition at line 251 of file generic_projector.h.

References libMesh::FEMContext::get_elem(), libMesh::Elem::JUST_COARSENED, libMesh::Elem::JUST_REFINED, libMesh::DofObject::old_dof_object, libMesh::Elem::parent(), and libMesh::Elem::refinement_flag().

252  {
253  LOG_SCOPE ("check_old_context(c)", "OldSolutionBase");
254  const Elem & elem = c.get_elem();
255  if (last_elem != &elem)
256  {
257  if (elem.refinement_flag() == Elem::JUST_REFINED)
258  {
259  old_context.pre_fe_reinit(sys, elem.parent());
260  }
261  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
262  {
263  libmesh_error();
264  }
265  else
266  {
267  if (!elem.old_dof_object)
268  {
269  libmesh_error();
270  }
271 
272  old_context.pre_fe_reinit(sys, &elem);
273  }
274 
275  last_elem = &elem;
276  }
277  else
278  {
279  libmesh_assert(old_context.has_elem());
280  }
281  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Definition: fem_context.C:1553
bool has_elem() const
Definition: fem_context.h:865
template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
bool libMesh::OldSolutionBase< Output, point_output >::check_old_context ( const FEMContext c,
const Point p 
)
inlineprotectedinherited

Definition at line 284 of file generic_projector.h.

References libMesh::Elem::child_ref_range(), libMesh::FEMContext::get_elem(), libMesh::Elem::hmax(), libMesh::Elem::JUST_COARSENED, libMesh::Elem::JUST_REFINED, libMesh::DofObject::old_dof_object, libMesh::Elem::parent(), libMesh::Real, and libMesh::Elem::refinement_flag().

285  {
286  LOG_SCOPE ("check_old_context(c,p)", "OldSolutionBase");
287  const Elem & elem = c.get_elem();
288  if (last_elem != &elem)
289  {
290  if (elem.refinement_flag() == Elem::JUST_REFINED)
291  {
292  old_context.pre_fe_reinit(sys, elem.parent());
293  }
294  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
295  {
296  // Find the child with this point. Use out_of_elem_tol
297  // (in physical space, which may correspond to a large
298  // tolerance in master space!) to allow for out-of-element
299  // finite differencing of mixed gradient terms. Pray we
300  // have no quadrature locations which are within 1e-5 of
301  // the element subdivision boundary but are not exactly on
302  // that boundary.
303  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
304 
305  for (auto & child : elem.child_ref_range())
306  if (child.close_to_point(p, master_tol))
307  {
308  old_context.pre_fe_reinit(sys, &child);
309  break;
310  }
311 
312  libmesh_assert
313  (old_context.get_elem().close_to_point(p, master_tol));
314  }
315  else
316  {
317  if (!elem.old_dof_object)
318  return false;
319 
320  old_context.pre_fe_reinit(sys, &elem);
321  }
322 
323  last_elem = &elem;
324  }
325  else
326  {
327  libmesh_assert(old_context.has_elem());
328 
329  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
330 
331  if (!old_context.get_elem().close_to_point(p, master_tol))
332  {
333  libmesh_assert_equal_to
334  (elem.refinement_flag(), Elem::JUST_COARSENED);
335 
336  for (auto & child : elem.child_ref_range())
337  if (child.close_to_point(p, master_tol))
338  {
339  old_context.pre_fe_reinit(sys, &child);
340  break;
341  }
342 
343  libmesh_assert
344  (old_context.get_elem().close_to_point(p, master_tol));
345  }
346  }
347 
348  return true;
349  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Definition: fem_context.C:1553
virtual bool close_to_point(const Point &p, Real tol) const
Definition: elem.C:2362
bool has_elem() const
Definition: fem_context.h:865
const Elem & get_elem() const
Definition: fem_context.h:871
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
Output libMesh::OldSolutionValue< Output, point_output >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned int  elem_dim,
const Node n,
Real  = 0. 
)
template<>
Number libMesh::OldSolutionValue< Number,&FEMContext::point_value >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned  int,
const Node n,
Real   
)
inline

Definition at line 474 of file generic_projector.h.

References libMesh::DofObject::dof_number(), libMesh::OldSolutionValue< Output, point_output >::eval_at_node(), libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), and libMesh::DofObject::old_dof_object.

479 {
480  LOG_SCOPE ("Number eval_at_node()", "OldSolutionValue");
481 
482  // Optimize for the common case, where this node was part of the
483  // old solution.
484  //
485  // Be sure to handle cases where the variable wasn't defined on
486  // this node (due to changing subdomain support) or where the
487  // variable has no components on this node (due to Elem order
488  // exceeding FE order)
489  if (n.old_dof_object &&
490  n.old_dof_object->n_vars(sys.number()) &&
491  n.old_dof_object->n_comp(sys.number(), i))
492  {
493  const dof_id_type old_id =
494  n.old_dof_object->dof_number(sys.number(), i, 0);
495  return old_solution(old_id);
496  }
497 
498  return this->eval_at_point(c, i, n, 0);
499 }
const NumericVector< Number > & old_solution
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
unsigned int number() const
Definition: system.h:2006
uint8_t dof_id_type
Definition: id_types.h:64
template<>
Gradient libMesh::OldSolutionValue< Gradient,&FEMContext::point_gradient >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned int  elem_dim,
const Node n,
Real   
)
inline

Definition at line 507 of file generic_projector.h.

References libMesh::DofObject::dof_number(), libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), and libMesh::DofObject::old_dof_object.

512 {
513  LOG_SCOPE ("Gradient eval_at_node()", "OldSolutionValue");
514 
515  // Optimize for the common case, where this node was part of the
516  // old solution.
517  //
518  // Be sure to handle cases where the variable wasn't defined on
519  // this node (due to changing subdomain support) or where the
520  // variable has no components on this node (due to Elem order
521  // exceeding FE order)
522  if (n.old_dof_object &&
523  n.old_dof_object->n_vars(sys.number()) &&
524  n.old_dof_object->n_comp(sys.number(), i))
525  {
526  Gradient g;
527  for (unsigned int d = 0; d != elem_dim; ++d)
528  {
529  const dof_id_type old_id =
530  n.old_dof_object->dof_number(sys.number(), i, d+1);
531  g(d) = old_solution(old_id);
532  }
533  return g;
534  }
535 
536  return this->eval_at_point(c, i, n, 0);
537 }
const NumericVector< Number > & old_solution
NumberVectorValue Gradient
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
unsigned int number() const
Definition: system.h:2006
uint8_t dof_id_type
Definition: id_types.h:64
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
Output libMesh::OldSolutionValue< Output, point_output >::eval_at_point ( const FEMContext c,
unsigned int  i,
const Point p,
Real  = 0. 
)
inline

Definition at line 400 of file generic_projector.h.

404  {
405  LOG_SCOPE ("eval_at_point()", "OldSolutionValue");
406 
407  if (!this->check_old_context(c, p))
408  return 0;
409 
410  Output n;
411  (this->old_context.*point_output)(i, p, n, this->out_of_elem_tol);
412  return n;
413  }
void check_old_context(const FEMContext &c)
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionValue< Output, point_output >::eval_old_dofs ( const FEMContext c,
unsigned int  var,
std::vector< Output > &  values 
)
inline

Definition at line 415 of file generic_projector.h.

418  {
419  LOG_SCOPE ("eval_old_dofs()", "OldSolutionValue");
420 
421  this->check_old_context(c);
422 
423  const std::vector<dof_id_type> & old_dof_indices =
424  this->old_context.get_dof_indices(var);
425 
426  libmesh_assert_equal_to (old_dof_indices.size(), values.size());
427 
428  old_solution.get(old_dof_indices, values);
429  }
void check_old_context(const FEMContext &c)
const NumericVector< Number > & old_solution
const std::vector< dof_id_type > & get_dof_indices() const
Definition: diff_context.h:367
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
static void libMesh::OldSolutionBase< Output, point_output >::get_shape_outputs ( FEBase fe)
staticinherited
template<>
void libMesh::OldSolutionBase< Number,&FEMContext::point_value >::get_shape_outputs ( FEBase fe)
inlineinherited

Definition at line 438 of file generic_projector.h.

References libMesh::FEGenericBase< OutputType >::get_phi().

439 {
440  fe.get_phi();
441 }
template<>
void libMesh::OldSolutionBase< Gradient,&FEMContext::point_gradient >::get_shape_outputs ( FEBase fe)
inlineinherited

Definition at line 446 of file generic_projector.h.

References libMesh::FEGenericBase< OutputType >::get_dphi().

447 {
448  fe.get_dphi();
449 }
template<>
void libMesh::OldSolutionBase< Real,&FEMContext::point_value >::get_shape_outputs ( FEBase fe)
inlineinherited

Definition at line 455 of file generic_projector.h.

References libMesh::FEGenericBase< OutputType >::get_phi().

456 {
457  fe.get_phi();
458 }
template<>
void libMesh::OldSolutionBase< RealGradient,&FEMContext::point_gradient >::get_shape_outputs ( FEBase fe)
inlineinherited
template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionBase< Output, point_output >::init_context ( FEMContext c)
inlineinherited

Definition at line 227 of file generic_projector.h.

References libMesh::FEMContext::DOFS_ONLY, libmesh_nullptr, and libMesh::FEMContext::set_algebraic_type().

228  {
229  c.set_algebraic_type(FEMContext::DOFS_ONLY);
230 
231  // Loop over variables, to prerequest
232  for (unsigned int var=0; var!=sys.n_vars(); ++var)
233  {
234  FEBase * fe = libmesh_nullptr;
235  const std::set<unsigned char> & elem_dims =
237 
238  for (std::set<unsigned char>::const_iterator dim_it =
239  elem_dims.begin(); dim_it != elem_dims.end(); ++dim_it)
240  {
241  const unsigned char dim = *dim_it;
242  old_context.get_element_fe( var, fe, dim );
243  get_shape_outputs(*fe);
244  }
245  }
246  }
const class libmesh_nullptr_t libmesh_nullptr
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Definition: fem_context.h:262
static void get_shape_outputs(FEBase &fe)
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:913
FEGenericBase< Real > FEBase
unsigned int n_vars() const
Definition: system.h:2086
template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
bool libMesh::OldSolutionBase< Output, point_output >::is_grid_projection ( )
inlineinherited

Definition at line 248 of file generic_projector.h.

248 { return true; }
template<>
const Real libMesh::OldSolutionBase< Number,&FEMContext::point_value >::out_of_elem_tol ( )
protectedinherited

Definition at line 544 of file generic_projector.h.

template<>
const Real libMesh::OldSolutionBase< Gradient,&FEMContext::point_gradient >::out_of_elem_tol ( )
protectedinherited

Definition at line 547 of file generic_projector.h.

template<>
const Real libMesh::OldSolutionBase< Real,&FEMContext::point_value >::out_of_elem_tol ( )
protectedinherited

Definition at line 551 of file generic_projector.h.

template<>
const Real libMesh::OldSolutionBase< RealGradient,&FEMContext::point_gradient >::out_of_elem_tol ( )
protectedinherited

Definition at line 554 of file generic_projector.h.

Member Data Documentation

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
const Elem* libMesh::OldSolutionBase< Output, point_output >::last_elem
protectedinherited

Definition at line 352 of file generic_projector.h.

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
FEMContext libMesh::OldSolutionBase< Output, point_output >::old_context
protectedinherited

Definition at line 354 of file generic_projector.h.

template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
const NumericVector<Number>& libMesh::OldSolutionValue< Output, point_output >::old_solution
private

Definition at line 432 of file generic_projector.h.

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
const Real libMesh::OldSolutionBase< Output, point_output >::out_of_elem_tol
staticprotectedinherited

Definition at line 356 of file generic_projector.h.

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
const System& libMesh::OldSolutionBase< Output, point_output >::sys
protectedinherited

Definition at line 353 of file generic_projector.h.


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