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

#include <generic_projector.h>

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

Public Member Functions

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

Static Public Member Functions

static void get_shape_outputs (FEBase &fe)
 

Protected Member Functions

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

Protected Attributes

const Elemlast_elem
 
const Systemsys
 
FEMContext old_context
 
std::vector< unsigned int > component_to_var
 

Static Protected Attributes

static const Real out_of_elem_tol
 

Private Attributes

const NumericVector< Number > & old_solution
 

Detailed Description

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

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

Author
Roy H. Stogner
Date
2016

Definition at line 382 of file generic_projector.h.

Constructor & Destructor Documentation

◆ OldSolutionValue() [1/2]

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

Definition at line 385 of file generic_projector.h.

References libMesh::FEMContext::OLD.

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

◆ OldSolutionValue() [2/2]

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

Definition at line 394 of file generic_projector.h.

References libMesh::FEMContext::OLD.

394  :
395  OldSolutionBase<Output, point_output>(in.sys),
396  old_solution(in.old_solution)
397  {
400  }
const NumericVector< Number > & old_solution
void set_algebraic_type(const AlgebraicType atype)
Definition: fem_context.h:948
void set_custom_solution(const NumericVector< Number > *custom_sol)
Definition: fem_context.h:963

Member Function Documentation

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

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

260  {
261  LOG_SCOPE ("check_old_context(c)", "OldSolutionBase");
262  const Elem & elem = c.get_elem();
263  if (last_elem != &elem)
264  {
265  if (elem.refinement_flag() == Elem::JUST_REFINED)
266  {
267  old_context.pre_fe_reinit(sys, elem.parent());
268  }
269  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
270  {
271  libmesh_error();
272  }
273  else
274  {
275  if (!elem.old_dof_object)
276  {
277  libmesh_error();
278  }
279 
280  old_context.pre_fe_reinit(sys, &elem);
281  }
282 
283  last_elem = &elem;
284  }
285  else
286  {
287  libmesh_assert(old_context.has_elem());
288  }
289  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Definition: fem_context.C:1552
bool has_elem() const
Definition: fem_context.h:865

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

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

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

◆ eval_at_node() [1/3]

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

◆ eval_at_node() [2/3]

template<>
Number libMesh::OldSolutionValue< Number, &FEMContext::point_value >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned  int,
const Node n,
Real   
)
inline

Definition at line 487 of file generic_projector.h.

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

492 {
493  LOG_SCOPE ("Number eval_at_node()", "OldSolutionValue");
494 
495  // Handle offset from non-scalar components in previous variables
496  libmesh_assert_less(i, this->component_to_var.size());
497  unsigned int var = this->component_to_var[i];
498 
499  // Optimize for the common case, where this node was part of the
500  // old solution.
501  //
502  // Be sure to handle cases where the variable wasn't defined on
503  // this node (due to changing subdomain support) or where the
504  // variable has no components on this node (due to Elem order
505  // exceeding FE order)
506  if (n.old_dof_object &&
507  n.old_dof_object->n_vars(sys.number()) &&
508  n.old_dof_object->n_comp(sys.number(), var))
509  {
510  const dof_id_type old_id =
511  n.old_dof_object->dof_number(sys.number(), var, 0);
512  return old_solution(old_id);
513  }
514 
515  return this->eval_at_point(c, i, n, 0);
516 }
const NumericVector< Number > & old_solution
unsigned int number() const
Definition: system.h:2025
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
std::vector< unsigned int > component_to_var
uint8_t dof_id_type
Definition: id_types.h:64

◆ eval_at_node() [3/3]

template<>
Gradient libMesh::OldSolutionValue< Gradient, &FEMContext::point_gradient >::eval_at_node ( const FEMContext c,
unsigned int  i,
unsigned int  elem_dim,
const Node n,
Real   
)
inline

Definition at line 524 of file generic_projector.h.

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

529 {
530  LOG_SCOPE ("Gradient eval_at_node()", "OldSolutionValue");
531 
532  // Handle offset from non-scalar components in previous variables
533  libmesh_assert_less(i, this->component_to_var.size());
534  unsigned int var = this->component_to_var[i];
535 
536  // Optimize for the common case, where this node was part of the
537  // old solution.
538  //
539  // Be sure to handle cases where the variable wasn't defined on
540  // this node (due to changing subdomain support) or where the
541  // variable has no components on this node (due to Elem order
542  // exceeding FE order)
543  if (n.old_dof_object &&
544  n.old_dof_object->n_vars(sys.number()) &&
545  n.old_dof_object->n_comp(sys.number(), var))
546  {
547  Gradient g;
548  for (unsigned int d = 0; d != elem_dim; ++d)
549  {
550  const dof_id_type old_id =
551  n.old_dof_object->dof_number(sys.number(), var, d+1);
552  g(d) = old_solution(old_id);
553  }
554  return g;
555  }
556 
557  return this->eval_at_point(c, i, n, 0);
558 }
const NumericVector< Number > & old_solution
unsigned int number() const
Definition: system.h:2025
NumberVectorValue Gradient
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
std::vector< unsigned int > component_to_var
uint8_t dof_id_type
Definition: id_types.h:64

◆ eval_at_point()

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
Output libMesh::OldSolutionValue< Output, point_output >::eval_at_point ( const FEMContext c,
unsigned int  i,
const Point p,
Real  = 0. 
)
inline

Definition at line 409 of file generic_projector.h.

413  {
414  LOG_SCOPE ("eval_at_point()", "OldSolutionValue");
415 
416  if (!this->check_old_context(c, p))
417  return 0;
418 
419  // Handle offset from non-scalar components in previous variables
420  libmesh_assert_less(i, this->component_to_var.size());
421  unsigned int var = this->component_to_var[i];
422 
423  Output n;
424  (this->old_context.*point_output)(var, p, n, this->out_of_elem_tol);
425  return n;
426  }
void check_old_context(const FEMContext &c)
std::vector< unsigned int > component_to_var

◆ eval_old_dofs()

template<typename Output , void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionValue< Output, point_output >::eval_old_dofs ( const FEMContext c,
unsigned int  var,
std::vector< Output > &  values 
)
inline

Definition at line 428 of file generic_projector.h.

431  {
432  LOG_SCOPE ("eval_old_dofs()", "OldSolutionValue");
433 
434  this->check_old_context(c);
435 
436  const std::vector<dof_id_type> & old_dof_indices =
437  this->old_context.get_dof_indices(var);
438 
439  libmesh_assert_equal_to (old_dof_indices.size(), values.size());
440 
441  old_solution.get(old_dof_indices, values);
442  }
void check_old_context(const FEMContext &c)
const NumericVector< Number > & old_solution
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
const std::vector< dof_id_type > & get_dof_indices() const
Definition: diff_context.h:367

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

◆ get_shape_outputs() [2/5]

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

Definition at line 451 of file generic_projector.h.

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

452 {
453  fe.get_phi();
454 }

◆ get_shape_outputs() [3/5]

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

Definition at line 459 of file generic_projector.h.

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

460 {
461  fe.get_dphi();
462 }

◆ get_shape_outputs() [4/5]

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

Definition at line 468 of file generic_projector.h.

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

469 {
470  fe.get_phi();
471 }

◆ get_shape_outputs() [5/5]

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

Definition at line 476 of file generic_projector.h.

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

477 {
478  fe.get_dphi();
479 }

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

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

238  {
239  c.set_algebraic_type(FEMContext::DOFS_ONLY);
240 
241  // Loop over variables, to prerequest
242  for (unsigned int var=0; var!=sys.n_vars(); ++var)
243  {
244  FEBase * fe = nullptr;
245  const std::set<unsigned char> & elem_dims =
247 
248  for (const auto & dim : elem_dims)
249  {
250  old_context.get_element_fe(var, fe, dim);
251  get_shape_outputs(*fe);
252  }
253  }
254  }
static void get_shape_outputs(FEBase &fe)
FEGenericBase< Real > FEBase
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Definition: fem_context.h:262
unsigned int n_vars() const
Definition: system.h:2105
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:913

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

256 { return true; }

◆ out_of_elem_tol() [1/4]

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

Definition at line 565 of file generic_projector.h.

◆ out_of_elem_tol() [2/4]

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

Definition at line 568 of file generic_projector.h.

◆ out_of_elem_tol() [3/4]

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

Definition at line 572 of file generic_projector.h.

◆ out_of_elem_tol() [4/4]

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

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

Definition at line 363 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 360 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 362 of file generic_projector.h.

◆ old_solution

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

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

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


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