libMesh
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | 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 Types

typedef TensorTools::MakeReal< Output >::type RealType
 

Public Member Functions

 OldSolutionBase (const libMesh::System &sys_in, const std::vector< unsigned int > *vars)
 
 OldSolutionBase (const OldSolutionBase &in)
 
void init_context (FEMContext &c)
 
bool is_grid_projection ()
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 
template<>
void get_shape_outputs (FEAbstract &fe)
 

Static Public Member Functions

static void get_shape_outputs (FEAbstract &fe)
 

Protected Types

typedef TensorTools::MakeBaseNumber< Output >::type DofValueType
 

Protected Member Functions

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
 
std::vector< unsigned intcomponent_to_var
 

Static Protected Attributes

static const Real out_of_elem_tol = 10 * TOLERANCE
 

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 524 of file generic_projector.h.

Member Typedef Documentation

◆ DofValueType

template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
typedef TensorTools::MakeBaseNumber<Output>::type libMesh::OldSolutionBase< Output, point_output >::DofValueType
protected

Definition at line 527 of file generic_projector.h.

◆ RealType

template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
typedef TensorTools::MakeReal<Output>::type libMesh::OldSolutionBase< Output, point_output >::RealType

Definition at line 529 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,
const std::vector< unsigned int > *  vars 
)
inline

Definition at line 531 of file generic_projector.h.

References libMesh::make_range().

532  :
533  last_elem(nullptr),
534  sys(sys_in),
535  old_context(sys_in, vars, /* allocate_local_matrices= */ false)
536  {
537  // We'll be queried for components but we'll typically be looking
538  // up data by variables, and those indices don't always match
539  auto make_lookup = [this](unsigned int v)
540  {
541  const unsigned int vcomp = sys.variable_scalar_number(v,0);
542  if (vcomp >= component_to_var.size())
543  component_to_var.resize(vcomp+1, static_cast<unsigned int>(-1));
544  component_to_var[vcomp] = v;
545  };
546 
547  if (vars)
548  for (auto v : *vars)
549  make_lookup(v);
550  else
551  for (auto v : make_range(sys.n_vars()))
552  make_lookup(v);
553  }
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2408
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
std::vector< unsigned int > component_to_var
unsigned int n_vars() const
Definition: system.h:2349

◆ 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 555 of file generic_projector.h.

555  :
556  last_elem(nullptr),
557  sys(in.sys),
558  old_context(sys, in.old_context.active_vars(), /* allocate_local_matrices= */ false),
559  component_to_var(in.component_to_var)
560  {
561  }
std::vector< unsigned int > component_to_var

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 596 of file generic_projector.h.

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

597  {
598  LOG_SCOPE ("check_old_context(c)", "OldSolutionBase");
599  const Elem & elem = c.get_elem();
600  if (last_elem != &elem)
601  {
602  if (elem.refinement_flag() == Elem::JUST_REFINED)
603  {
604  old_context.pre_fe_reinit(sys, elem.parent());
605  }
606  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
607  {
608  libmesh_error();
609  }
610  else
611  {
612  if (!elem.get_old_dof_object())
613  {
614  libmesh_error();
615  }
616 
617  old_context.pre_fe_reinit(sys, &elem);
618  }
619 
620  last_elem = &elem;
621  }
622  else
623  {
625  }
626  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1678
libmesh_assert(ctx)
bool has_elem() const
Test for current Elem object.
Definition: fem_context.h:902

◆ 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 629 of file generic_projector.h.

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

630  {
631  LOG_SCOPE ("check_old_context(c,p)", "OldSolutionBase");
632  const Elem & elem = c.get_elem();
633  if (last_elem != &elem)
634  {
635  if (elem.refinement_flag() == Elem::JUST_REFINED)
636  {
637  old_context.pre_fe_reinit(sys, elem.parent());
638  }
639  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
640  {
641  // Find the child with this point. Use out_of_elem_tol
642  // (in physical space, which may correspond to a large
643  // tolerance in master space!) to allow for out-of-element
644  // finite differencing of mixed gradient terms. Pray we
645  // have no quadrature locations which are within 1e-5 of
646  // the element subdivision boundary but are not exactly on
647  // that boundary.
648  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
649 
650  for (auto & child : elem.child_ref_range())
651  if (child.close_to_point(p, master_tol))
652  {
653  old_context.pre_fe_reinit(sys, &child);
654  break;
655  }
656 
658  (old_context.get_elem().close_to_point(p, master_tol));
659  }
660  else
661  {
662  if (!elem.get_old_dof_object())
663  return false;
664 
665  old_context.pre_fe_reinit(sys, &elem);
666  }
667 
668  last_elem = &elem;
669  }
670  else
671  {
673 
674  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
675 
676  if (!old_context.get_elem().close_to_point(p, master_tol))
677  {
678  libmesh_assert_equal_to
679  (elem.refinement_flag(), Elem::JUST_COARSENED);
680 
681  for (auto & child : elem.child_ref_range())
682  if (child.close_to_point(p, master_tol))
683  {
684  old_context.pre_fe_reinit(sys, &child);
685  break;
686  }
687 
689  (old_context.get_elem().close_to_point(p, master_tol));
690  }
691  }
692 
693  return true;
694  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1678
const Elem & get_elem() const
Accessor for current Elem object.
Definition: fem_context.h:908
libmesh_assert(ctx)
virtual bool close_to_point(const Point &p, Real tol) const
Definition: elem.C:2400
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const Real out_of_elem_tol
bool has_elem() const
Test for current Elem object.
Definition: fem_context.h:902

◆ get_shape_outputs() [1/9]

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 ( FEAbstract fe)
static

◆ get_shape_outputs() [2/9]

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

Definition at line 944 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

945 {
946  fe.request_phi();
947 }

◆ get_shape_outputs() [3/9]

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

Definition at line 952 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

953 {
954  fe.request_dphi();
955 }

◆ get_shape_outputs() [4/9]

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

Definition at line 959 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

960 {
961  fe.request_phi();
962 }

◆ get_shape_outputs() [5/9]

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

Definition at line 967 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

968 {
969  fe.request_dphi();
970 }

◆ get_shape_outputs() [6/9]

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

Definition at line 976 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

977 {
978  fe.request_phi();
979 }

◆ get_shape_outputs() [7/9]

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

Definition at line 984 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

985 {
986  fe.request_dphi();
987 }

◆ get_shape_outputs() [8/9]

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

Definition at line 991 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

992 {
993  fe.request_phi();
994 }

◆ get_shape_outputs() [9/9]

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

Definition at line 999 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

1000 {
1001  fe.request_dphi();
1002 }

◆ 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 567 of file generic_projector.h.

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

568  {
569  c.set_algebraic_type(FEMContext::DOFS_ONLY);
570 
571  const std::set<unsigned char> & elem_dims =
573 
574  // Loop over variables and dimensions, to prerequest
575  for (const auto & dim : elem_dims)
576  {
577  FEAbstract * fe = nullptr;
578  if (old_context.active_vars())
579  for (auto var : *old_context.active_vars())
580  {
581  old_context.get_element_fe(var, fe, dim);
582  get_shape_outputs(*fe);
583  }
584  else
585  for (auto var : make_range(sys.n_vars()))
586  {
587  old_context.get_element_fe(var, fe, dim);
588  get_shape_outputs(*fe);
589  }
590  }
591  }
unsigned int dim
static void get_shape_outputs(FEAbstract &fe)
const std::vector< unsigned int > * active_vars() const
Return a pointer to the vector of active variables being computed for, or a null pointer if all varia...
Definition: fem_context.h:1034
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
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:277
unsigned int n_vars() const
Definition: system.h:2349
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:951

◆ 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 593 of file generic_projector.h.

593 { return true; }

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 700 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 697 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 699 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 = 10 * TOLERANCE
staticprotected

Definition at line 702 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 698 of file generic_projector.h.


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