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 517 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 520 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 522 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 521 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 524 of file system_projection.C.

525  :
526  OldSolutionBase<Output, point_output>(sys_in, vars)
527  {
529  }
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 531 of file system_projection.C.

531  :
532  OldSolutionBase<Output, point_output>(in.sys, in.old_context.active_vars())
533  {
535  }
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:2776
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 790 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().

796 {
797  LOG_SCOPE ("Real eval_at_node()", "OldSolutionCoefs");
798 
799  // Optimize for the common case, where this node was part of the
800  // old solution.
801  //
802  // Be sure to handle cases where the variable wasn't defined on
803  // this node (due to changing subdomain support) or where the
804  // variable has no components on this node (due to Elem order
805  // exceeding FE order) or where the old_dof_object dofs might
806  // correspond to non-vertex dofs (due to extra_hanging_dofs and
807  // refinement)
808 
809  const Elem::RefinementState flag = c.get_elem().refinement_flag();
810 
811  const DofObject * old_dof_object = n.get_old_dof_object();
812  if (old_dof_object &&
813  (!extra_hanging_dofs ||
814  flag == Elem::JUST_COARSENED ||
815  flag == Elem::DO_NOTHING) &&
816  old_dof_object->n_vars(sys.number()) &&
817  old_dof_object->n_comp(sys.number(), i))
818  {
819  DynamicSparseNumberArray<Real, dof_id_type> returnval;
820  const dof_id_type old_id =
821  old_dof_object->dof_number(sys.number(), i, 0);
822  returnval.resize(1);
823  returnval.raw_at(0) = 1;
824  returnval.raw_index(0) = old_id;
825  return returnval;
826  }
827 
828  return this->eval_at_point(c, i, n, 0, false);
829 }
RefinementState
Enumeration of possible element refinement states.
Definition: elem.h:1452
unsigned int number() const
Definition: system.h:2350
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 837 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().

843 {
844  LOG_SCOPE ("RealGradient eval_at_node()", "OldSolutionCoefs");
845 
846  // Optimize for the common case, where this node was part of the
847  // old solution.
848  //
849  // Be sure to handle cases where the variable wasn't defined on
850  // this node (due to changing subdomain support) or where the
851  // variable has no components on this node (due to Elem order
852  // exceeding FE order) or where the old_dof_object dofs might
853  // correspond to non-vertex dofs (due to extra_hanging_dofs and
854  // refinement)
855 
856  const Elem::RefinementState flag = c.get_elem().refinement_flag();
857 
858  const DofObject * old_dof_object = n.get_old_dof_object();
859  if (old_dof_object &&
860  (!extra_hanging_dofs ||
861  flag == Elem::JUST_COARSENED ||
862  flag == Elem::DO_NOTHING) &&
863  old_dof_object->n_vars(sys.number()) &&
864  old_dof_object->n_comp(sys.number(), i))
865  {
866  VectorValue<DynamicSparseNumberArray<Real, dof_id_type> > g;
867  for (unsigned int d = 0; d != elem_dim; ++d)
868  {
869  const dof_id_type old_id =
870  old_dof_object->dof_number(sys.number(), i, d+1);
871  g(d).resize(1);
872  g(d).raw_at(0) = 1;
873  g(d).raw_index(0) = old_id;
874  }
875  return g;
876  }
877 
878  return this->eval_at_point(c, i, n, 0, false);
879 }
RefinementState
Enumeration of possible element refinement states.
Definition: elem.h:1452
unsigned int number() const
Definition: system.h:2350
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 694 of file system_projection.C.

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

699 {
700  LOG_SCOPE ("eval_at_point()", "OldSolutionCoefs");
701 
702  if (!skip_context_check)
703  if (!this->check_old_context(c, p))
704  return 0;
705 
706  // Get finite element object
707  FEGenericBase<Real> * fe = nullptr;
709  (i, fe, this->old_context.get_elem_dim());
710 
711  // Build a FE for calculating phi(p)
712  FEGenericBase<Real> * fe_new =
713  this->old_context.build_new_fe(fe, p);
714 
715  // Get the values and global indices of the shape functions
716  const std::vector<std::vector<Real> > & phi = fe_new->get_phi();
717  const std::vector<dof_id_type> & dof_indices =
718  this->old_context.get_dof_indices(i);
719 
720  const std::size_t n_dofs = phi.size();
721  libmesh_assert_equal_to(n_dofs, dof_indices.size());
722 
723  DynamicSparseNumberArray<Real, dof_id_type> returnval;
724  returnval.resize(n_dofs);
725 
726  for (auto j : index_range(phi))
727  {
728  returnval.raw_at(j) = phi[j][0];
729  returnval.raw_index(j) = dof_indices[j];
730  }
731 
732  return returnval;
733 }
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:2625
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:117

◆ 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 741 of file system_projection.C.

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

746 {
747  LOG_SCOPE ("eval_at_point()", "OldSolutionCoefs");
748 
749  if (!skip_context_check)
750  if (!this->check_old_context(c, p))
751  return 0;
752 
753  // Get finite element object
754  FEGenericBase<Real> * fe = nullptr;
756  (i, fe, this->old_context.get_elem_dim());
757 
758  // Build a FE for calculating phi(p)
759  FEGenericBase<Real> * fe_new =
760  this->old_context.build_new_fe(fe, p);
761 
762  // Get the values and global indices of the shape functions
763  const std::vector<std::vector<RealGradient> > & dphi = fe_new->get_dphi();
764  const std::vector<dof_id_type> & dof_indices =
765  this->old_context.get_dof_indices(i);
766 
767  const std::size_t n_dofs = dphi.size();
768  libmesh_assert_equal_to(n_dofs, dof_indices.size());
769 
770  VectorValue<DynamicSparseNumberArray<Real, dof_id_type> > returnval;
771 
772  for (unsigned int d = 0; d != LIBMESH_DIM; ++d)
773  returnval(d).resize(n_dofs);
774 
775  for (auto j : index_range(dphi))
776  for (int d = 0; d != LIBMESH_DIM; ++d)
777  {
778  returnval(d).raw_at(j) = dphi[j][0](d);
779  returnval(d).raw_index(j) = dof_indices[j];
780  }
781 
782  return returnval;
783 }
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:2625
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:117

◆ 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 550 of file system_projection.C.

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

555  {
556  LOG_SCOPE ("eval_mixed_derivatives", "OldSolutionCoefs");
557 
558  // This should only be called on vertices
559  libmesh_assert_less(c.get_elem().get_node_index(&n),
560  c.get_elem().n_vertices());
561 
562  // Handle offset from non-scalar components in previous variables
563  libmesh_assert_less(i, this->component_to_var.size());
564  unsigned int var = this->component_to_var[i];
565 
566  // We have 1 mixed derivative in 2D, 4 in 3D
567  const unsigned int n_mixed = (dim-1) * (dim-1);
568  derivs.resize(n_mixed);
569 
570  // Be sure to handle cases where the variable wasn't defined on
571  // this node (e.g. due to changing subdomain support)
572  const DofObject * old_dof_object = n.get_old_dof_object();
573  if (old_dof_object &&
574  old_dof_object->n_vars(this->sys.number()) &&
575  old_dof_object->n_comp(this->sys.number(), var))
576  {
577  const dof_id_type first_old_id =
578  old_dof_object->dof_number(this->sys.number(), var, dim);
579  std::vector<dof_id_type> old_ids(n_mixed);
580  std::iota(old_ids.begin(), old_ids.end(), first_old_id);
581 
582  for (auto d_i : index_range(derivs))
583  {
584  derivs[d_i].resize(1);
585  derivs[d_i].raw_at(0) = 1;
586  derivs[d_i].raw_index(0) = old_ids[d_i];
587  }
588  }
589  else
590  {
591  std::fill(derivs.begin(), derivs.end(), 0);
592  }
593  }
unsigned int dim
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
unsigned int number() const
Definition: system.h:2350
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:117
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 596 of file system_projection.C.

References libMesh::index_range().

601  {
602  LOG_SCOPE ("eval_old_dofs(node)", "OldSolutionCoefs");
603 
604  // We may be reusing a std::vector here, but the following
605  // dof_indices call appends without first clearing.
606  indices.clear();
607 
608  this->sys.get_dof_map().dof_indices(elem, node_num, indices, var_num);
609 
610  std::vector<dof_id_type> old_indices;
611 
612  this->sys.get_dof_map().old_dof_indices(elem, node_num, old_indices, var_num);
613 
614  libmesh_assert_equal_to (old_indices.size(), indices.size());
615 
616  values.resize(old_indices.size());
617 
618  for (auto i : index_range(values))
619  {
620  values[i].resize(1);
621  values[i].raw_at(0) = 1;
622  values[i].raw_index(0) = old_indices[i];
623  }
624  }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2164
const DofMap & get_dof_map() const
Definition: system.h:2374
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:117
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:2418

◆ 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 627 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().

633  {
634  LOG_SCOPE ("eval_old_dofs(elem)", "OldSolutionCoefs");
635 
636  // We're only to be asked for old dofs on elements that can copy
637  // them through DO_NOTHING or through refinement.
638  const Elem & old_elem =
639  (elem.refinement_flag() == Elem::JUST_REFINED) ?
640  *elem.parent() : elem;
641 
642  // If there are any element-based DOF numbers, get them
643  const unsigned int nc =
644  FEInterface::n_dofs_per_elem(fe_type, &elem);
645 
646  std::vector<dof_id_type> old_dof_indices(nc);
647  indices.resize(nc);
648 
649  // We should never have fewer dofs than necessary on an
650  // element unless we're getting indices on a parent element,
651  // and we should never need those indices
652  if (nc != 0)
653  {
654  const DofObject & old_dof_object = old_elem.get_old_dof_object_ref();
655 
656  const auto [vg, vig] =
657  elem.var_to_vg_and_offset(sys_num,var_num);
658 
659  const unsigned int n_comp = elem.n_comp_group(sys_num,vg);
660  libmesh_assert_greater(elem.n_systems(), sys_num);
661  libmesh_assert_greater_equal(n_comp, nc);
662 
663  for (unsigned int i=0; i<nc; i++)
664  {
665  const dof_id_type d_old =
666  old_dof_object.dof_number(sys_num, vg, vig, i, n_comp);
667  const dof_id_type d_new =
668  elem.dof_number(sys_num, vg, vig, i, n_comp);
669  libmesh_assert_not_equal_to (d_old, DofObject::invalid_id);
670  libmesh_assert_not_equal_to (d_new, DofObject::invalid_id);
671 
672  old_dof_indices[i] = d_old;
673  indices[i] = d_new;
674  }
675  }
676 
677  values.resize(old_dof_indices.size());
678 
679  for (auto i : index_range(values))
680  {
681  values[i].resize(1);
682  values[i].raw_at(0) = 1;
683  values[i].raw_index(0) = old_dof_indices[i];
684  }
685  }
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:530
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
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:117
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:140
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:2430
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: