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

#include <generic_projector.h>

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

Public Member Functions

 OldSolutionBase (const libMesh::System &sys_in)
 
 OldSolutionBase (const OldSolutionBase &in)
 
void init_context (FEMContext &c)
 
bool is_grid_projection ()
 
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)
 

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

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
 

Detailed Description

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

The OldSolutionBase input functor abstract base class is the root of the OldSolutionValue and OldSolutionCoefs classes which allow a GenericProjector to read old solution values or solution interpolation coefficients for a just-refined-and-coarsened mesh.

Author
Roy H. Stogner
Date
2016

Definition at line 206 of file generic_projector.h.

Constructor & Destructor Documentation

◆ OldSolutionBase() [1/2]

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

Definition at line 209 of file generic_projector.h.

209  :
210  last_elem(nullptr),
211  sys(sys_in),
212  old_context(sys_in)
213  {
214  // We'll be queried for components but we'll typically be looking
215  // up data by variables, and those indices don't always match
216  for (auto v : IntRange<unsigned int>(0, sys.n_vars()))
217  {
218  const unsigned int vcomp = sys.variable_scalar_number(v,0);
219  if (vcomp >= component_to_var.size())
220  component_to_var.resize(vcomp+1, static_cast<unsigned int>(-1));
221  component_to_var[vcomp] = v;
222  }
223  }
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2164
std::vector< unsigned int > component_to_var
unsigned int n_vars() const
Definition: system.h:2105

◆ OldSolutionBase() [2/2]

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

Definition at line 225 of file generic_projector.h.

225  :
226  last_elem(nullptr),
227  sys(in.sys),
228  old_context(sys),
229  component_to_var(in.component_to_var)
230  {
231  }
std::vector< unsigned int > component_to_var

Member Function Documentation

◆ check_old_context() [1/2]

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

Definition at line 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 
)
inlineprotected

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

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

◆ get_shape_outputs() [2/5]

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

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

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

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

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

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 ( )
inline

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 ( )
protected

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 ( )
protected

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 ( )
protected

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 ( )
protected

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
protected

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
protected

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
protected

Definition at line 362 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
staticprotected

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
protected

Definition at line 361 of file generic_projector.h.


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