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

Public Member Functions

 OldSolutionValue (const libMesh::System &sys_in, const NumericVector< Number > &old_sol)
 
 OldSolutionValue (const OldSolutionValue &in)
 
void init_context (FEMContext &c)
 
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.)
 
bool is_grid_projection ()
 
void eval_old_dofs (const FEMContext &c, unsigned int var, std::vector< Output > &values)
 
template<>
void get_shape_outputs (FEBase &fe)
 
template<>
void get_shape_outputs (FEBase &fe)
 
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)
 

Static Public Member Functions

static void get_shape_outputs (FEBase &fe)
 

Protected Member Functions

void check_old_context (const FEMContext &c)
 
bool check_old_context (const FEMContext &c, const Point &p)
 

Private Member Functions

template<>
const Real out_of_elem_tol
 
template<>
const Real out_of_elem_tol
 

Private Attributes

const Elemlast_elem
 
const Systemsys
 
FEMContext old_context
 
const NumericVector< Number > & old_solution
 

Static Private Attributes

static const Real out_of_elem_tol
 

Detailed Description

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

Definition at line 185 of file system_projection.C.

Constructor & Destructor Documentation

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

References libMesh::FEMContext::OLD.

189  :
191  sys(sys_in),
192  old_context(sys_in),
193  old_solution(old_sol)
194  {
197  }
const NumericVector< Number > & old_solution
const class libmesh_nullptr_t libmesh_nullptr
void set_algebraic_type(const AlgebraicType atype)
Definition: fem_context.h:879
void set_custom_solution(const NumericVector< Number > *custom_sol)
Definition: fem_context.h:894
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 199 of file system_projection.C.

References libMesh::FEMContext::OLD.

199  :
201  sys(in.sys),
202  old_context(sys),
203  old_solution(in.old_solution)
204  {
207  }
const NumericVector< Number > & old_solution
const class libmesh_nullptr_t libmesh_nullptr
void set_algebraic_type(const AlgebraicType atype)
Definition: fem_context.h:879
void set_custom_solution(const NumericVector< Number > *custom_sol)
Definition: fem_context.h:894

Member Function Documentation

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

Definition at line 276 of file system_projection.C.

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

277  {
278  LOG_SCOPE ("check_old_context(c)", "OldSolutionValue");
279  const Elem & elem = c.get_elem();
280  if (last_elem != &elem)
281  {
282  if (elem.refinement_flag() == Elem::JUST_REFINED)
283  {
284  old_context.pre_fe_reinit(sys, elem.parent());
285  }
286  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
287  {
288  libmesh_error();
289  }
290  else
291  {
292  if (!elem.old_dof_object)
293  {
294  libmesh_error();
295  }
296 
297  old_context.pre_fe_reinit(sys, &elem);
298  }
299 
300  last_elem = &elem;
301  }
302  else
303  {
305  }
306  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Definition: fem_context.C:1561
bool has_elem() const
Definition: fem_context.h:798
libmesh_assert(j)
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
bool libMesh::OldSolutionValue< Output, point_output >::check_old_context ( const FEMContext c,
const Point p 
)
inlineprotected

Definition at line 309 of file system_projection.C.

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

310  {
311  LOG_SCOPE ("check_old_context(c,p)", "OldSolutionValue");
312  const Elem & elem = c.get_elem();
313  if (last_elem != &elem)
314  {
315  if (elem.refinement_flag() == Elem::JUST_REFINED)
316  {
317  old_context.pre_fe_reinit(sys, elem.parent());
318  }
319  else if (elem.refinement_flag() == Elem::JUST_COARSENED)
320  {
321  // Find the child with this point. Use out_of_elem_tol
322  // (in physical space, which may correspond to a large
323  // tolerance in master space!) to allow for out-of-element
324  // finite differencing of mixed gradient terms. Pray we
325  // have no quadrature locations which are within 1e-5 of
326  // the element subdivision boundary but are not exactly on
327  // that boundary.
328  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
329 
330  for (unsigned int c=0; c != elem.n_children(); ++c)
331  if (elem.child_ptr(c)->close_to_point(p, master_tol))
332  {
333  old_context.pre_fe_reinit(sys, elem.child_ptr(c));
334  break;
335  }
336 
338  (old_context.get_elem().close_to_point(p, master_tol));
339  }
340  else
341  {
342  if (!elem.old_dof_object)
343  return false;
344 
345  old_context.pre_fe_reinit(sys, &elem);
346  }
347 
348  last_elem = &elem;
349  }
350  else
351  {
353 
354  const Real master_tol = out_of_elem_tol / elem.hmax() * 2;
355 
356  if (!old_context.get_elem().close_to_point(p, master_tol))
357  {
358  libmesh_assert_equal_to
359  (elem.refinement_flag(), Elem::JUST_COARSENED);
360 
361  for (unsigned int c=0; c != elem.n_children(); ++c)
362  if (elem.child_ptr(c)->close_to_point(p, master_tol))
363  {
364  old_context.pre_fe_reinit(sys, elem.child_ptr(c));
365  break;
366  }
367 
369  (old_context.get_elem().close_to_point(p, master_tol));
370  }
371  }
372 
373  return true;
374  }
virtual void pre_fe_reinit(const System &, const Elem *e)
Definition: fem_context.C:1561
virtual bool close_to_point(const Point &p, Real tol) const
Definition: elem.C:2321
bool has_elem() const
Definition: fem_context.h:798
const Elem & get_elem() const
Definition: fem_context.h:804
libmesh_assert(j)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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. 
)
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 406 of file system_projection.C.

References libMesh::DofObject::dof_number(), libMesh::OldSolutionValue< Output, point_output >::eval_at_node(), libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), libMesh::System::number(), libMesh::DofObject::old_dof_object, and libMesh::sys.

411 {
412  LOG_SCOPE ("Number eval_at_node()", "OldSolutionValue");
413 
414  // Optimize for the common case, where this node was part of the
415  // old solution.
416  //
417  // Be sure to handle cases where the variable wasn't defined on
418  // this node (due to changing subdomain support) or where the
419  // variable has no components on this node (due to Elem order
420  // exceeding FE order)
421  if (n.old_dof_object &&
422  n.old_dof_object->n_vars(sys.number()) &&
423  n.old_dof_object->n_comp(sys.number(), i))
424  {
425  const dof_id_type old_id =
426  n.old_dof_object->dof_number(sys.number(), i, 0);
427  return old_solution(old_id);
428  }
429 
430  return this->eval_at_point(c, i, n, 0);
431 }
const NumericVector< Number > & old_solution
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
unsigned int number() const
Definition: system.h:1995
uint8_t dof_id_type
Definition: id_types.h:64
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 439 of file system_projection.C.

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

444 {
445  LOG_SCOPE ("Gradient eval_at_node()", "OldSolutionValue");
446 
447  // Optimize for the common case, where this node was part of the
448  // old solution.
449  //
450  // Be sure to handle cases where the variable wasn't defined on
451  // this node (due to changing subdomain support) or where the
452  // variable has no components on this node (due to Elem order
453  // exceeding FE order)
454  if (n.old_dof_object &&
455  n.old_dof_object->n_vars(sys.number()) &&
456  n.old_dof_object->n_comp(sys.number(), i))
457  {
458  Gradient g;
459  for (unsigned int d = 0; d != elem_dim; ++d)
460  {
461  const dof_id_type old_id =
462  n.old_dof_object->dof_number(sys.number(), i, d+1);
463  g(d) = old_solution(old_id);
464  }
465  return g;
466  }
467 
468  return this->eval_at_point(c, i, n, 0);
469 }
const NumericVector< Number > & old_solution
NumberVectorValue Gradient
Output eval_at_point(const FEMContext &c, unsigned int i, const Point &p, Real=0.)
unsigned int number() const
Definition: system.h:1995
uint8_t dof_id_type
Definition: id_types.h:64
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 242 of file system_projection.C.

246  {
247  LOG_SCOPE ("eval_at_point()", "OldSolutionValue");
248 
249  if (!this->check_old_context(c, p))
250  return 0;
251 
252  Output n;
253  (old_context.*point_output)(i, p, n, out_of_elem_tol);
254  return n;
255  }
void check_old_context(const FEMContext &c)
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 259 of file system_projection.C.

262  {
263  LOG_SCOPE ("eval_old_dofs()", "OldSolutionValue");
264 
265  this->check_old_context(c);
266 
267  const std::vector<dof_id_type> & old_dof_indices =
269 
270  libmesh_assert_equal_to (old_dof_indices.size(), values.size());
271 
272  old_solution.get(old_dof_indices, values);
273  }
const NumericVector< Number > & old_solution
const std::vector< dof_id_type > & get_dof_indices() const
Definition: diff_context.h:366
void check_old_context(const FEMContext &c)
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
static void libMesh::OldSolutionValue< Output, point_output >::get_shape_outputs ( FEBase fe)
static
template<>
void libMesh::OldSolutionValue< Number,&FEMContext::point_value >::get_shape_outputs ( FEBase fe)
inline

Definition at line 388 of file system_projection.C.

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

389 {
390  fe.get_phi();
391 }
template<>
void libMesh::OldSolutionValue< Gradient,&FEMContext::point_gradient >::get_shape_outputs ( FEBase fe)
inline
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
void libMesh::OldSolutionValue< Output, point_output >::init_context ( FEMContext c)
inline

Definition at line 213 of file system_projection.C.

References libMesh::FEMContext::DOFS_ONLY, libmesh_nullptr, libMesh::System::n_vars(), libMesh::Real, libMesh::FEMContext::set_algebraic_type(), and libMesh::sys.

214  {
215  c.set_algebraic_type(FEMContext::DOFS_ONLY);
216 
217  // Loop over variables, to prerequest
218  for (unsigned int var=0; var!=sys.n_vars(); ++var)
219  {
220  FEBase * fe = libmesh_nullptr;
221  const std::set<unsigned char> & elem_dims =
223 
224  for (std::set<unsigned char>::const_iterator dim_it =
225  elem_dims.begin(); dim_it != elem_dims.end(); ++dim_it)
226  {
227  const unsigned char dim = *dim_it;
228  old_context.get_element_fe( var, fe, dim );
229  get_shape_outputs(*fe);
230  }
231  }
232  }
const class libmesh_nullptr_t libmesh_nullptr
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Definition: fem_context.h:235
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:846
static void get_shape_outputs(FEBase &fe)
FEGenericBase< Real > FEBase
unsigned int n_vars() const
Definition: system.h:2075
template<typename Output, void(FEMContext::*)(unsigned int, const Point &, Output &, const Real) const point_output>
bool libMesh::OldSolutionValue< Output, point_output >::is_grid_projection ( )
inline

Definition at line 257 of file system_projection.C.

257 { return true; }
template<>
const Real libMesh::OldSolutionValue< Number,&FEMContext::point_value >::out_of_elem_tol ( )
private

Definition at line 476 of file system_projection.C.

template<>
const Real libMesh::OldSolutionValue< Gradient,&FEMContext::point_gradient >::out_of_elem_tol ( )
private

Definition at line 479 of file system_projection.C.

Member Data Documentation

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

Definition at line 377 of file system_projection.C.

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

Definition at line 379 of file system_projection.C.

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

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

Definition at line 382 of file system_projection.C.

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

Definition at line 378 of file system_projection.C.


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