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::OldSolutionCoefs< Output, point_output > Class Template Reference

The OldSolutionCoefs input functor class can be used with GenericProjector to read solution transfer coefficients on a just-refined-and-coarsened mesh. More...

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

Public Types

typedef DSNAOutput< Output >::type DSNA
 
typedef DSNA ValuePushType
 
typedef DSNA FunctorValue
 
typedef TensorTools::MakeReal< Output >::type RealType
 

Public Member Functions

 OldSolutionCoefs (const libMesh::System &sys_in, const std::vector< unsigned int > *vars)
 
 OldSolutionCoefs (const OldSolutionCoefs &in)
 
DSNA eval_at_node (const FEMContext &c, unsigned int i, unsigned int elem_dim, const Node &n, bool extra_hanging_dofs, Real=0.)
 
DSNA eval_at_point (const FEMContext &c, unsigned int i, const Point &p, Real time, bool skip_context_check)
 
void eval_mixed_derivatives (const FEMContext &libmesh_dbg_var(c), unsigned int i, unsigned int dim, const Node &n, std::vector< DSNA > &derivs)
 
void eval_old_dofs (const Elem &elem, unsigned int node_num, unsigned int var_num, std::vector< dof_id_type > &indices, std::vector< DSNA > &values)
 
void eval_old_dofs (const Elem &elem, const FEType &fe_type, unsigned int sys_num, unsigned int var_num, std::vector< dof_id_type > &indices, std::vector< DSNA > &values)
 
template<>
DynamicSparseNumberArray< Real, dof_id_typeeval_at_point (const FEMContext &c, unsigned int i, const Point &p, Real, bool skip_context_check)
 
template<>
VectorValue< DynamicSparseNumberArray< Real, dof_id_type > > eval_at_point (const FEMContext &c, unsigned int i, const Point &p, Real, bool skip_context_check)
 
template<>
DynamicSparseNumberArray< Real, dof_id_typeeval_at_node (const FEMContext &c, unsigned int i, unsigned int, const Node &n, bool extra_hanging_dofs, Real)
 
template<>
VectorValue< DynamicSparseNumberArray< Real, dof_id_type > > eval_at_node (const FEMContext &c, unsigned int i, unsigned int elem_dim, const Node &n, bool extra_hanging_dofs, Real)
 
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)
 
void init_context (FEMContext &c)
 
bool is_grid_projection ()
 

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::OldSolutionCoefs< Output, point_output >

The OldSolutionCoefs input functor class can be used with GenericProjector to read solution transfer coefficients on a just-refined-and-coarsened mesh.

Author
Roy H. Stogner
Date
2017

Definition at line 538 of file system_projection.C.

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
protectedinherited

Definition at line 540 of file generic_projector.h.

◆ DSNA

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
typedef DSNAOutput<Output>::type libMesh::OldSolutionCoefs< Output, point_output >::DSNA

Definition at line 541 of file system_projection.C.

◆ FunctorValue

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
typedef DSNA libMesh::OldSolutionCoefs< Output, point_output >::FunctorValue

Definition at line 543 of file system_projection.C.

◆ 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
inherited

Definition at line 542 of file generic_projector.h.

◆ ValuePushType

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
typedef DSNA libMesh::OldSolutionCoefs< Output, point_output >::ValuePushType

Definition at line 542 of file system_projection.C.

Constructor & Destructor Documentation

◆ OldSolutionCoefs() [1/2]

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

Definition at line 545 of file system_projection.C.

546  :
547  OldSolutionBase<Output, point_output>(sys_in, vars)
548  {
550  }
void set_algebraic_type(const AlgebraicType atype)
Setting which determines whether to initialize algebraic structures (elem_*) on each element and set ...
Definition: fem_context.h:986

◆ OldSolutionCoefs() [2/2]

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

Definition at line 552 of file system_projection.C.

552  :
553  OldSolutionBase<Output, point_output>(in.sys, in.old_context.active_vars())
554  {
556  }
void set_algebraic_type(const AlgebraicType atype)
Setting which determines whether to initialize algebraic structures (elem_*) on each element and set ...
Definition: fem_context.h:986

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

Definition at line 609 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().

610  {
611  LOG_SCOPE ("check_old_context(c)", "OldSolutionBase");
612  const Elem & elem = c.get_elem();
613  if (last_elem != &elem)
614  {
615  if (elem.refinement_flag() == Elem::JUST_REFINED)
616  {
617  old_context.pre_fe_reinit(sys, elem.parent());
618  }
619  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
620  {
621  libmesh_error();
622  }
623  else
624  {
625  if (!elem.get_old_dof_object())
626  {
627  libmesh_error();
628  }
629 
630  old_context.pre_fe_reinit(sys, &elem);
631  }
632 
633  last_elem = &elem;
634  }
635  else
636  {
638  }
639  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1683
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 
)
inlineprotectedinherited

Definition at line 642 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().

643  {
644  LOG_SCOPE ("check_old_context(c,p)", "OldSolutionBase");
645  const Elem & elem = c.get_elem();
646  if (last_elem != &elem)
647  {
648  if (elem.refinement_flag() == Elem::JUST_REFINED)
649  {
650  old_context.pre_fe_reinit(sys, elem.parent());
651  }
652  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
653  {
654  // Find the child with this point. Use out_of_elem_tol
655  // (in physical space, which may correspond to a large
656  // tolerance in master space!) to allow for out-of-element
657  // finite differencing of mixed gradient terms. Pray we
658  // have no quadrature locations which are within 1e-5 of
659  // the element subdivision boundary but are not exactly on
660  // that boundary.
661  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
662 
663  for (auto & child : elem.child_ref_range())
664  if (child.close_to_point(p, master_tol))
665  {
666  old_context.pre_fe_reinit(sys, &child);
667  break;
668  }
669 
671  (old_context.get_elem().close_to_point(p, master_tol));
672  }
673  else
674  {
675  if (!elem.get_old_dof_object())
676  return false;
677 
678  old_context.pre_fe_reinit(sys, &elem);
679  }
680 
681  last_elem = &elem;
682  }
683  else
684  {
686 
687  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
688 
689  if (!old_context.get_elem().close_to_point(p, master_tol))
690  {
691  libmesh_assert_equal_to
692  (elem.refinement_flag(), Elem::JUST_COARSENED);
693 
694  for (auto & child : elem.child_ref_range())
695  if (child.close_to_point(p, master_tol))
696  {
697  old_context.pre_fe_reinit(sys, &child);
698  break;
699  }
700 
702  (old_context.get_elem().close_to_point(p, master_tol));
703  }
704  }
705 
706  return true;
707  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1683
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:2809
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

◆ eval_at_node() [1/3]

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
DSNA libMesh::OldSolutionCoefs< Output, point_output >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned int  elem_dim,
const Node n,
bool  extra_hanging_dofs,
Real  = 0. 
)

◆ eval_at_node() [2/3]

template<>
DynamicSparseNumberArray< Real, dof_id_type > libMesh::OldSolutionCoefs< Real, &FEMContext::point_value >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned  int,
const Node n,
bool  extra_hanging_dofs,
Real   
)
inline

Definition at line 811 of file system_projection.C.

References libMesh::DofObject::dof_number(), libMesh::FEMContext::get_elem(), libMesh::DofObject::get_old_dof_object(), libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), and libMesh::Elem::refinement_flag().

817 {
818  LOG_SCOPE ("Real eval_at_node()", "OldSolutionCoefs");
819 
820  // Optimize for the common case, where this node was part of the
821  // old solution.
822  //
823  // Be sure to handle cases where the variable wasn't defined on
824  // this node (due to changing subdomain support) or where the
825  // variable has no components on this node (due to Elem order
826  // exceeding FE order) or where the old_dof_object dofs might
827  // correspond to non-vertex dofs (due to extra_hanging_dofs and
828  // refinement)
829 
830  const Elem::RefinementState flag = c.get_elem().refinement_flag();
831 
832  const DofObject * old_dof_object = n.get_old_dof_object();
833  if (old_dof_object &&
834  (!extra_hanging_dofs ||
835  flag == Elem::JUST_COARSENED ||
836  flag == Elem::DO_NOTHING) &&
837  old_dof_object->n_vars(sys.number()) &&
838  old_dof_object->n_comp(sys.number(), i))
839  {
840  DynamicSparseNumberArray<Real, dof_id_type> returnval;
841  const dof_id_type old_id =
842  old_dof_object->dof_number(sys.number(), i, 0);
843  returnval.resize(1);
844  returnval.raw_at(0) = 1;
845  returnval.raw_index(0) = old_id;
846  return returnval;
847  }
848 
849  return this->eval_at_point(c, i, n, 0, false);
850 }
RefinementState
Enumeration of possible element refinement states.
Definition: elem.h:1443
unsigned int number() const
Definition: system.h:2393
DSNA eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real time, bool skip_context_check)
uint8_t dof_id_type
Definition: id_types.h:67

◆ eval_at_node() [3/3]

template<>
VectorValue< DynamicSparseNumberArray< Real, dof_id_type > > libMesh::OldSolutionCoefs< RealGradient, &FEMContext::point_gradient >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned int  elem_dim,
const Node n,
bool  extra_hanging_dofs,
Real   
)
inline

Definition at line 858 of file system_projection.C.

References libMesh::DofObject::dof_number(), libMesh::FEMContext::get_elem(), libMesh::DofObject::get_old_dof_object(), libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), and libMesh::Elem::refinement_flag().

864 {
865  LOG_SCOPE ("RealGradient eval_at_node()", "OldSolutionCoefs");
866 
867  // Optimize for the common case, where this node was part of the
868  // old solution.
869  //
870  // Be sure to handle cases where the variable wasn't defined on
871  // this node (due to changing subdomain support) or where the
872  // variable has no components on this node (due to Elem order
873  // exceeding FE order) or where the old_dof_object dofs might
874  // correspond to non-vertex dofs (due to extra_hanging_dofs and
875  // refinement)
876 
877  const Elem::RefinementState flag = c.get_elem().refinement_flag();
878 
879  const DofObject * old_dof_object = n.get_old_dof_object();
880  if (old_dof_object &&
881  (!extra_hanging_dofs ||
882  flag == Elem::JUST_COARSENED ||
883  flag == Elem::DO_NOTHING) &&
884  old_dof_object->n_vars(sys.number()) &&
885  old_dof_object->n_comp(sys.number(), i))
886  {
887  VectorValue<DynamicSparseNumberArray<Real, dof_id_type> > g;
888  for (unsigned int d = 0; d != elem_dim; ++d)
889  {
890  const dof_id_type old_id =
891  old_dof_object->dof_number(sys.number(), i, d+1);
892  g(d).resize(1);
893  g(d).raw_at(0) = 1;
894  g(d).raw_index(0) = old_id;
895  }
896  return g;
897  }
898 
899  return this->eval_at_point(c, i, n, 0, false);
900 }
RefinementState
Enumeration of possible element refinement states.
Definition: elem.h:1443
unsigned int number() const
Definition: system.h:2393
DSNA eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real time, bool skip_context_check)
uint8_t dof_id_type
Definition: id_types.h:67

◆ eval_at_point() [1/3]

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
DSNA libMesh::OldSolutionCoefs< Output, point_output >::eval_at_point ( const FEMContext c,
unsigned int  i,
const Point p,
Real  time,
bool  skip_context_check 
)

◆ eval_at_point() [2/3]

template<>
DynamicSparseNumberArray< Real, dof_id_type > libMesh::OldSolutionCoefs< Real, &FEMContext::point_value >::eval_at_point ( const FEMContext c,
unsigned int  i,
const Point p,
Real  ,
bool  skip_context_check 
)
inline

Definition at line 715 of file system_projection.C.

References libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::index_range(), and libMesh::Real.

720 {
721  LOG_SCOPE ("eval_at_point()", "OldSolutionCoefs");
722 
723  if (!skip_context_check)
724  if (!this->check_old_context(c, p))
725  return 0;
726 
727  // Get finite element object
728  FEGenericBase<Real> * fe = nullptr;
730  (i, fe, this->old_context.get_elem_dim());
731 
732  // Build a FE for calculating phi(p)
733  FEGenericBase<Real> * fe_new =
734  this->old_context.build_new_fe(fe, p);
735 
736  // Get the values and global indices of the shape functions
737  const std::vector<std::vector<Real> > & phi = fe_new->get_phi();
738  const std::vector<dof_id_type> & dof_indices =
739  this->old_context.get_dof_indices(i);
740 
741  const std::size_t n_dofs = phi.size();
742  libmesh_assert_equal_to(n_dofs, dof_indices.size());
743 
744  DynamicSparseNumberArray<Real, dof_id_type> returnval;
745  returnval.resize(n_dofs);
746 
747  for (auto j : index_range(phi))
748  {
749  returnval.raw_at(j) = phi[j][0];
750  returnval.raw_index(j) = dof_indices[j];
751  }
752 
753  return returnval;
754 }
void check_old_context(const FEMContext &c)
unsigned char get_elem_dim() const
Definition: fem_context.h:944
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
Definition: diff_context.h:363
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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
FEGenericBase< OutputShape > * build_new_fe(const FEGenericBase< OutputShape > *fe, const Point &p, const Real tolerance=TOLERANCE, const int get_derivative_level=-1) const
Helper function to reduce some code duplication in the *_point_* methods.
Definition: fem_context.C:2023
template class LIBMESH_EXPORT FEGenericBase< Real >
Definition: fe_base.C:2589
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153

◆ eval_at_point() [3/3]

template<>
VectorValue< DynamicSparseNumberArray< Real, dof_id_type > > libMesh::OldSolutionCoefs< RealGradient, &FEMContext::point_gradient >::eval_at_point ( const FEMContext c,
unsigned int  i,
const Point p,
Real  ,
bool  skip_context_check 
)
inline

Definition at line 762 of file system_projection.C.

References libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::index_range(), and libMesh::Real.

767 {
768  LOG_SCOPE ("eval_at_point()", "OldSolutionCoefs");
769 
770  if (!skip_context_check)
771  if (!this->check_old_context(c, p))
772  return 0;
773 
774  // Get finite element object
775  FEGenericBase<Real> * fe = nullptr;
777  (i, fe, this->old_context.get_elem_dim());
778 
779  // Build a FE for calculating phi(p)
780  FEGenericBase<Real> * fe_new =
781  this->old_context.build_new_fe(fe, p);
782 
783  // Get the values and global indices of the shape functions
784  const std::vector<std::vector<RealGradient> > & dphi = fe_new->get_dphi();
785  const std::vector<dof_id_type> & dof_indices =
786  this->old_context.get_dof_indices(i);
787 
788  const std::size_t n_dofs = dphi.size();
789  libmesh_assert_equal_to(n_dofs, dof_indices.size());
790 
791  VectorValue<DynamicSparseNumberArray<Real, dof_id_type> > returnval;
792 
793  for (unsigned int d = 0; d != LIBMESH_DIM; ++d)
794  returnval(d).resize(n_dofs);
795 
796  for (auto j : index_range(dphi))
797  for (int d = 0; d != LIBMESH_DIM; ++d)
798  {
799  returnval(d).raw_at(j) = dphi[j][0](d);
800  returnval(d).raw_index(j) = dof_indices[j];
801  }
802 
803  return returnval;
804 }
void check_old_context(const FEMContext &c)
unsigned char get_elem_dim() const
Definition: fem_context.h:944
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
Definition: diff_context.h:363
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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
FEGenericBase< OutputShape > * build_new_fe(const FEGenericBase< OutputShape > *fe, const Point &p, const Real tolerance=TOLERANCE, const int get_derivative_level=-1) const
Helper function to reduce some code duplication in the *_point_* methods.
Definition: fem_context.C:2023
template class LIBMESH_EXPORT FEGenericBase< Real >
Definition: fe_base.C:2589
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153

◆ eval_mixed_derivatives()

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionCoefs< Output, point_output >::eval_mixed_derivatives ( const FEMContext libmesh_dbg_varc,
unsigned int  i,
unsigned int  dim,
const Node n,
std::vector< DSNA > &  derivs 
)
inline

Definition at line 571 of file system_projection.C.

References dim, libMesh::DofObject::dof_number(), libMesh::DofObject::get_old_dof_object(), libMesh::index_range(), libMesh::DofObject::n_comp(), and libMesh::DofObject::n_vars().

576  {
577  LOG_SCOPE ("eval_mixed_derivatives", "OldSolutionCoefs");
578 
579  // This should only be called on vertices
580  libmesh_assert_less(c.get_elem().get_node_index(&n),
581  c.get_elem().n_vertices());
582 
583  // Handle offset from non-scalar components in previous variables
584  libmesh_assert_less(i, this->component_to_var.size());
585  unsigned int var = this->component_to_var[i];
586 
587  // We have 1 mixed derivative in 2D, 4 in 3D
588  const unsigned int n_mixed = (dim-1) * (dim-1);
589  derivs.resize(n_mixed);
590 
591  // Be sure to handle cases where the variable wasn't defined on
592  // this node (e.g. due to changing subdomain support)
593  const DofObject * old_dof_object = n.get_old_dof_object();
594  if (old_dof_object &&
595  old_dof_object->n_vars(this->sys.number()) &&
596  old_dof_object->n_comp(this->sys.number(), var))
597  {
598  const dof_id_type first_old_id =
599  old_dof_object->dof_number(this->sys.number(), var, dim);
600  std::vector<dof_id_type> old_ids(n_mixed);
601  std::iota(old_ids.begin(), old_ids.end(), first_old_id);
602 
603  for (auto d_i : index_range(derivs))
604  {
605  derivs[d_i].resize(1);
606  derivs[d_i].raw_at(0) = 1;
607  derivs[d_i].raw_index(0) = old_ids[d_i];
608  }
609  }
610  else
611  {
612  std::fill(derivs.begin(), derivs.end(), 0);
613  }
614  }
unsigned int dim
unsigned int number() const
Definition: system.h:2393
std::vector< unsigned int > component_to_var
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
uint8_t dof_id_type
Definition: id_types.h:67

◆ eval_old_dofs() [1/2]

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionCoefs< Output, point_output >::eval_old_dofs ( const Elem elem,
unsigned int  node_num,
unsigned int  var_num,
std::vector< dof_id_type > &  indices,
std::vector< DSNA > &  values 
)
inline

Definition at line 617 of file system_projection.C.

References libMesh::index_range().

622  {
623  LOG_SCOPE ("eval_old_dofs(node)", "OldSolutionCoefs");
624 
625  // We may be reusing a std::vector here, but the following
626  // dof_indices call appends without first clearing.
627  indices.clear();
628 
629  this->sys.get_dof_map().dof_indices(elem, node_num, indices, var_num);
630 
631  std::vector<dof_id_type> old_indices;
632 
633  this->sys.get_dof_map().old_dof_indices(elem, node_num, old_indices, var_num);
634 
635  libmesh_assert_equal_to (old_indices.size(), indices.size());
636 
637  values.resize(old_indices.size());
638 
639  for (auto i : index_range(values))
640  {
641  values[i].resize(1);
642  values[i].raw_at(0) = 1;
643  values[i].raw_index(0) = old_indices[i];
644  }
645  }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2201
const DofMap & get_dof_map() const
Definition: system.h:2417
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
void old_dof_indices(const Elem &elem, unsigned int n, std::vector< dof_id_type > &di, const unsigned int vn) const
Appends to the vector di the old global degree of freedom indices for elem.node_ref(n), for one variable vn.
Definition: dof_map.C:2478

◆ eval_old_dofs() [2/2]

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionCoefs< Output, point_output >::eval_old_dofs ( const Elem elem,
const FEType fe_type,
unsigned int  sys_num,
unsigned int  var_num,
std::vector< dof_id_type > &  indices,
std::vector< DSNA > &  values 
)
inline

Definition at line 648 of file system_projection.C.

References libMesh::DofObject::dof_number(), libMesh::DofObject::get_old_dof_object_ref(), libMesh::index_range(), libMesh::DofObject::n_comp_group(), libMesh::DofObject::n_systems(), libMesh::Elem::parent(), libMesh::Elem::refinement_flag(), and libMesh::DofObject::var_to_vg_and_offset().

654  {
655  LOG_SCOPE ("eval_old_dofs(elem)", "OldSolutionCoefs");
656 
657  // We're only to be asked for old dofs on elements that can copy
658  // them through DO_NOTHING or through refinement.
659  const Elem & old_elem =
660  (elem.refinement_flag() == Elem::JUST_REFINED) ?
661  *elem.parent() : elem;
662 
663  // If there are any element-based DOF numbers, get them
664  const unsigned int nc =
665  FEInterface::n_dofs_per_elem(fe_type, &elem);
666 
667  std::vector<dof_id_type> old_dof_indices(nc);
668  indices.resize(nc);
669 
670  // We should never have fewer dofs than necessary on an
671  // element unless we're getting indices on a parent element,
672  // and we should never need those indices
673  if (nc != 0)
674  {
675  const DofObject & old_dof_object = old_elem.get_old_dof_object_ref();
676 
677  const auto [vg, vig] =
678  elem.var_to_vg_and_offset(sys_num,var_num);
679 
680  const unsigned int n_comp = elem.n_comp_group(sys_num,vg);
681  libmesh_assert_greater(elem.n_systems(), sys_num);
682  libmesh_assert_greater_equal(n_comp, nc);
683 
684  for (unsigned int i=0; i<nc; i++)
685  {
686  const dof_id_type d_old =
687  old_dof_object.dof_number(sys_num, vg, vig, i, n_comp);
688  const dof_id_type d_new =
689  elem.dof_number(sys_num, vg, vig, i, n_comp);
690  libmesh_assert_not_equal_to (d_old, DofObject::invalid_id);
691  libmesh_assert_not_equal_to (d_new, DofObject::invalid_id);
692 
693  old_dof_indices[i] = d_old;
694  indices[i] = d_new;
695  }
696  }
697 
698  values.resize(old_dof_indices.size());
699 
700  for (auto i : index_range(values))
701  {
702  values[i].resize(1);
703  values[i].raw_at(0) = 1;
704  values[i].raw_index(0) = old_dof_indices[i];
705  }
706  }
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:531
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:473
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
uint8_t dof_id_type
Definition: id_types.h:67

◆ 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)
staticinherited

◆ get_shape_outputs() [2/9]

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

Definition at line 957 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

958 {
959  fe.request_phi();
960 }

◆ get_shape_outputs() [3/9]

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

Definition at line 965 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

966 {
967  fe.request_dphi();
968 }

◆ get_shape_outputs() [4/9]

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

Definition at line 972 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

973 {
974  fe.request_phi();
975 }

◆ get_shape_outputs() [5/9]

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

Definition at line 980 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

981 {
982  fe.request_dphi();
983 }

◆ get_shape_outputs() [6/9]

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

Definition at line 989 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

990 {
991  fe.request_phi();
992 }

◆ get_shape_outputs() [7/9]

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

Definition at line 997 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

998 {
999  fe.request_dphi();
1000 }

◆ get_shape_outputs() [8/9]

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

Definition at line 1004 of file generic_projector.h.

References libMesh::FEAbstract::request_phi().

1005 {
1006  fe.request_phi();
1007 }

◆ get_shape_outputs() [9/9]

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

Definition at line 1012 of file generic_projector.h.

References libMesh::FEAbstract::request_dphi().

1013 {
1014  fe.request_dphi();
1015 }

◆ 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)
inlineinherited

Definition at line 580 of file generic_projector.h.

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

581  {
582  c.set_algebraic_type(FEMContext::DOFS_ONLY);
583 
584  const std::set<unsigned char> & elem_dims =
586 
587  // Loop over variables and dimensions, to prerequest
588  for (const auto & dim : elem_dims)
589  {
590  FEAbstract * fe = nullptr;
591  if (old_context.active_vars())
592  for (auto var : *old_context.active_vars())
593  {
594  old_context.get_element_fe(var, fe, dim);
595  get_shape_outputs(*fe);
596  }
597  else
598  for (auto var : make_range(sys.n_vars()))
599  {
600  old_context.get_element_fe(var, fe, dim);
601  get_shape_outputs(*fe);
602  }
603  }
604  }
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:176
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.C:2674
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 ( )
inlineinherited

Definition at line 606 of file generic_projector.h.

606 { 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
protectedinherited

Definition at line 713 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
protectedinherited

Definition at line 710 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
protectedinherited

Definition at line 712 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
staticprotectedinherited

Definition at line 715 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
protectedinherited

Definition at line 711 of file generic_projector.h.


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