libMesh
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libMesh::OldSolutionBase< Output, point_output > Class Template Reference

The OldSolutionBase input functor abstract base class is the root of the OldSolutionValue and OldSolutionCoefs classes which allow a GenericProjector to read old solution values or solution interpolation coefficients for a just-refined-and-coarsened mesh. More...

#include <generic_projector.h>

Inheritance diagram for libMesh::OldSolutionBase< Output, point_output >:
[legend]

Public Member Functions

 OldSolutionBase (const libMesh::System &sys_in)
 
 OldSolutionBase (const OldSolutionBase &in)
 
void init_context (FEMContext &c)
 
bool is_grid_projection ()
 
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)
 

Static Public Member Functions

static void get_shape_outputs (FEBase &fe)
 

Protected Member Functions

void check_old_context (const FEMContext &c)
 
bool check_old_context (const FEMContext &c, const Point &p)
 
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
 

Protected Attributes

const Elemlast_elem
 
const Systemsys
 
FEMContext old_context
 
std::vector< unsigned intcomponent_to_var
 

Static Protected Attributes

static const Real out_of_elem_tol
 

Detailed Description

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

The OldSolutionBase input functor abstract base class is the root of the OldSolutionValue and OldSolutionCoefs classes which allow a GenericProjector to read old solution values or solution interpolation coefficients for a just-refined-and-coarsened mesh.

Author
Roy H. Stogner
Date
2016

Definition at line 479 of file generic_projector.h.

Constructor & Destructor Documentation

◆ OldSolutionBase() [1/2]

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

Definition at line 482 of file generic_projector.h.

482  :
483  last_elem(nullptr),
484  sys(sys_in),
485  old_context(sys_in)
486  {
487  // We'll be queried for components but we'll typically be looking
488  // up data by variables, and those indices don't always match
489  for (auto v : IntRange<unsigned int>(0, sys.n_vars()))
490  {
491  const unsigned int vcomp = sys.variable_scalar_number(v,0);
492  if (vcomp >= component_to_var.size())
493  component_to_var.resize(vcomp+1, static_cast<unsigned int>(-1));
494  component_to_var[vcomp] = v;
495  }
496  }

◆ OldSolutionBase() [2/2]

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

Definition at line 498 of file generic_projector.h.

498  :
499  last_elem(nullptr),
500  sys(in.sys),
501  old_context(sys),
502  component_to_var(in.component_to_var)
503  {
504  }

Member Function Documentation

◆ check_old_context() [1/2]

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)
inlineprotected

Definition at line 532 of file generic_projector.h.

533  {
534  LOG_SCOPE ("check_old_context(c)", "OldSolutionBase");
535  const Elem & elem = c.get_elem();
536  if (last_elem != &elem)
537  {
538  if (elem.refinement_flag() == Elem::JUST_REFINED)
539  {
540  old_context.pre_fe_reinit(sys, elem.parent());
541  }
542  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
543  {
544  libmesh_error();
545  }
546  else
547  {
548  if (!elem.old_dof_object)
549  {
550  libmesh_error();
551  }
552 
553  old_context.pre_fe_reinit(sys, &elem);
554  }
555 
556  last_elem = &elem;
557  }
558  else
559  {
561  }
562  }

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

◆ check_old_context() [2/2]

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 
)
inlineprotected

Definition at line 565 of file generic_projector.h.

566  {
567  LOG_SCOPE ("check_old_context(c,p)", "OldSolutionBase");
568  const Elem & elem = c.get_elem();
569  if (last_elem != &elem)
570  {
571  if (elem.refinement_flag() == Elem::JUST_REFINED)
572  {
573  old_context.pre_fe_reinit(sys, elem.parent());
574  }
575  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
576  {
577  // Find the child with this point. Use out_of_elem_tol
578  // (in physical space, which may correspond to a large
579  // tolerance in master space!) to allow for out-of-element
580  // finite differencing of mixed gradient terms. Pray we
581  // have no quadrature locations which are within 1e-5 of
582  // the element subdivision boundary but are not exactly on
583  // that boundary.
584  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
585 
586  for (auto & child : elem.child_ref_range())
587  if (child.close_to_point(p, master_tol))
588  {
589  old_context.pre_fe_reinit(sys, &child);
590  break;
591  }
592 
594  (old_context.get_elem().close_to_point(p, master_tol));
595  }
596  else
597  {
598  if (!elem.old_dof_object)
599  return false;
600 
601  old_context.pre_fe_reinit(sys, &elem);
602  }
603 
604  last_elem = &elem;
605  }
606  else
607  {
609 
610  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
611 
612  if (!old_context.get_elem().close_to_point(p, master_tol))
613  {
614  libmesh_assert_equal_to
615  (elem.refinement_flag(), Elem::JUST_COARSENED);
616 
617  for (auto & child : elem.child_ref_range())
618  if (child.close_to_point(p, master_tol))
619  {
620  old_context.pre_fe_reinit(sys, &child);
621  break;
622  }
623 
625  (old_context.get_elem().close_to_point(p, master_tol));
626  }
627  }
628 
629  return true;
630  }

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

◆ get_shape_outputs() [1/5]

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)
static

◆ get_shape_outputs() [2/5]

template<>
void libMesh::OldSolutionBase< Number, &FEMContext::point_value >::get_shape_outputs ( FEBase fe)
inline

Definition at line 789 of file generic_projector.h.

790 {
791  fe.get_phi();
792 }

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

◆ get_shape_outputs() [3/5]

template<>
void libMesh::OldSolutionBase< Gradient, &FEMContext::point_gradient >::get_shape_outputs ( FEBase fe)
inline

Definition at line 797 of file generic_projector.h.

798 {
799  fe.get_dphi();
800 }

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

◆ get_shape_outputs() [4/5]

template<>
void libMesh::OldSolutionBase< Real, &FEMContext::point_value >::get_shape_outputs ( FEBase fe)
inline

Definition at line 806 of file generic_projector.h.

807 {
808  fe.get_phi();
809 }

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

◆ get_shape_outputs() [5/5]

template<>
void libMesh::OldSolutionBase< RealGradient, &FEMContext::point_gradient >::get_shape_outputs ( FEBase fe)
inline

Definition at line 814 of file generic_projector.h.

815 {
816  fe.get_dphi();
817 }

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

◆ init_context()

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)
inline

Definition at line 510 of file generic_projector.h.

511  {
512  c.set_algebraic_type(FEMContext::DOFS_ONLY);
513 
514  // Loop over variables, to prerequest
515  for (auto var : IntRange<unsigned int>(0, sys.n_vars()))
516  {
517  FEBase * fe = nullptr;
518  const std::set<unsigned char> & elem_dims =
520 
521  for (const auto & dim : elem_dims)
522  {
523  old_context.get_element_fe(var, fe, dim);
524  get_shape_outputs(*fe);
525  }
526  }
527  }

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

◆ is_grid_projection()

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

Definition at line 529 of file generic_projector.h.

529 { return true; }

◆ out_of_elem_tol() [1/4]

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

Definition at line 929 of file generic_projector.h.

◆ out_of_elem_tol() [2/4]

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

Definition at line 932 of file generic_projector.h.

◆ out_of_elem_tol() [3/4]

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

Definition at line 936 of file generic_projector.h.

◆ out_of_elem_tol() [4/4]

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

Definition at line 939 of file generic_projector.h.

Member Data Documentation

◆ component_to_var

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
std::vector<unsigned int> libMesh::OldSolutionBase< Output, point_output >::component_to_var
protected

Definition at line 636 of file generic_projector.h.

◆ last_elem

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

Definition at line 633 of file generic_projector.h.

◆ old_context

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

Definition at line 635 of file generic_projector.h.

◆ out_of_elem_tol

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
staticprotected

Definition at line 638 of file generic_projector.h.

◆ sys

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

Definition at line 634 of file generic_projector.h.


The documentation for this class was generated from the following file:
libMesh::System::n_vars
unsigned int n_vars() const
Definition: system.h:2155
libMesh::Elem::JUST_REFINED
Definition: elem.h:1172
libMesh::Elem::close_to_point
virtual bool close_to_point(const Point &p, Real tol) const
Definition: elem.C:2119
libMesh::FEMContext::pre_fe_reinit
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1642
libMesh::FEMContext::get_elem
const Elem & get_elem() const
Accessor for current Elem object.
Definition: fem_context.h:896
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::OldSolutionBase::component_to_var
std::vector< unsigned int > component_to_var
Definition: generic_projector.h:636
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::System::variable_scalar_number
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2214
libMesh::FEMContext::has_elem
bool has_elem() const
Test for current Elem object.
Definition: fem_context.h:890
libMesh::FEBase
FEGenericBase< Real > FEBase
Definition: exact_error_estimator.h:39
libMesh::Elem::JUST_COARSENED
Definition: elem.h:1173
libMesh::OldSolutionBase::sys
const System & sys
Definition: generic_projector.h:634
libMesh::FEMContext::get_element_fe
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
Definition: fem_context.h:275
libMesh::OldSolutionBase::out_of_elem_tol
const Real out_of_elem_tol
Definition: generic_projector.h:929
libMesh::FEMContext::DOFS_ONLY
Definition: fem_context.h:959
libMesh::OldSolutionBase::last_elem
const Elem * last_elem
Definition: generic_projector.h:633
libMesh::FEMContext::elem_dimensions
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:938
libMesh::OldSolutionBase::old_context
FEMContext old_context
Definition: generic_projector.h:635
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::OldSolutionBase::get_shape_outputs
static void get_shape_outputs(FEBase &fe)