libMesh
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices Struct Reference

#include <generic_projector.h>

Inheritance diagram for libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices:
[legend]

Public Member Functions

 ProjectVertices (GenericProjector &p)
 
 ProjectVertices (ProjectVertices &p_v, Threads::split)
 
void operator() (const node_range &range)
 
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_id (dof_id_type id, const InsertInput &val, processor_id_type pid)
 
template<typename InsertInput , typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_id (dof_id_type id, const InsertInput &val, processor_id_type pid)
 
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_ids (const std::vector< dof_id_type > &ids, const std::vector< InsertInput > &vals, processor_id_type pid)
 
template<typename InsertInput , typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_ids (const std::vector< dof_id_type > &ids, const std::vector< InsertInput > &vals, processor_id_type pid)
 
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_id (dof_id_type id, const InsertInput &val, processor_id_type pid)
 
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void insert_ids (const std::vector< dof_id_type > &ids, const std::vector< InsertInput > &vals, processor_id_type pid)
 
void find_dofs_to_send (const Node &node, const Elem &elem, unsigned short node_num, const var_set &vars)
 
void join (const SubFunctor &other)
 

Public Attributes

ProjectionAction action
 
FFunctor f
 
std::unique_ptr< GFunctor > g
 
const Systemsystem
 
FEMContext context
 
std::vector< FEContinuityconts
 
std::vector< FEFieldTypefield_types
 
GenericProjectorprojector
 
std::unordered_map< dof_id_type, std::pair< typename FFunctor::ValuePushType, processor_id_type > > new_ids_to_push
 
std::unordered_map< dof_id_type, typename FFunctor::ValuePushType > new_ids_to_save
 

Protected Member Functions

void construct_projection (const std::vector< dof_id_type > &dof_indices_var, const std::vector< unsigned int > &involved_dofs, unsigned int var_component, const Node *node, const FEGenericBase< typename FFunctor::RealType > &fe)
 

Detailed Description

template<typename FFunctor, typename GFunctor, typename FValue, typename ProjectionAction>
struct libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices

Definition at line 307 of file generic_projector.h.

Constructor & Destructor Documentation

◆ ProjectVertices() [1/2]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::ProjectVertices ( GenericProjector p)
inline

Definition at line 308 of file generic_projector.h.

308 : SubProjector(p) {}

◆ ProjectVertices() [2/2]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::ProjectVertices ( ProjectVertices p_v,
Threads::split   
)
inline

Definition at line 310 of file generic_projector.h.

310 : SubProjector(p_v.projector) {}

Member Function Documentation

◆ construct_projection()

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection ( const std::vector< dof_id_type > &  dof_indices_var,
const std::vector< unsigned int > &  involved_dofs,
unsigned int  var_component,
const Node node,
const FEGenericBase< typename FFunctor::RealType > &  fe 
)
protectedinherited

Definition at line 2998 of file generic_projector.h.

References libMesh::C_ONE, libMesh::DenseMatrix< T >::cholesky_solve(), libMesh::FEAbstract::get_continuity(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::DenseVector< T >::get_values(), libMesh::FEAbstract::get_xyz(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ids_to_save, libMesh::TensorTools::inner_product(), libMesh::DofObject::invalid_processor_id, libMesh::make_range(), libMesh::DofObject::processor_id(), libMesh::DenseVector< T >::size(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::system, and libMesh::System::time.

3003 {
3004  const auto & JxW = fe.get_JxW();
3005  const auto & phi = fe.get_phi();
3006  const std::vector<std::vector<typename FEGenericBase<typename FFunctor::RealType>::OutputGradient>> * dphi = nullptr;
3007  const std::vector<Point> & xyz_values = fe.get_xyz();
3008  const FEContinuity cont = fe.get_continuity();
3009  const std::unordered_map<dof_id_type, typename FFunctor::ValuePushType> & ids_to_save =
3010  this->projector.ids_to_save;
3011 
3012  if (cont == C_ONE)
3013  dphi = &(fe.get_dphi());
3014 
3015  const unsigned int n_involved_dofs =
3016  cast_int<unsigned int>(involved_dofs.size());
3017 
3018  std::vector<dof_id_type> free_dof_ids;
3019  DenseVector<typename FFunctor::ValuePushType> Uinvolved(n_involved_dofs);
3020  std::vector<char> dof_is_fixed(n_involved_dofs, false); // bools
3021 
3022  for (auto i : make_range(n_involved_dofs))
3023  {
3024  const dof_id_type id = dof_indices_var[involved_dofs[i]];
3025  auto iter = ids_to_save.find(id);
3026  if (iter == ids_to_save.end())
3027  free_dof_ids.push_back(id);
3028  else
3029  {
3030  dof_is_fixed[i] = true;
3031  Uinvolved(i) = iter->second;
3032  }
3033  }
3034 
3035  const unsigned int free_dofs = free_dof_ids.size();
3036 
3037  // There may be nothing to project
3038  if (!free_dofs)
3039  return;
3040 
3041  // The element matrix and RHS for projections.
3042  // Note that Ke is always real-valued, whereas
3043  // Fe may be complex valued if complex number
3044  // support is enabled
3045  DenseMatrix<Real> Ke(free_dofs, free_dofs);
3046  DenseVector<typename FFunctor::ValuePushType> Fe(free_dofs);
3047  // The new degree of freedom coefficients to solve for
3048  DenseVector<typename FFunctor::ValuePushType> Ufree(free_dofs);
3049 
3050  const unsigned int n_qp =
3051  cast_int<unsigned int>(xyz_values.size());
3052 
3053  // Loop over the quadrature points
3054  for (unsigned int qp=0; qp<n_qp; qp++)
3055  {
3056  // solution at the quadrature point
3057  FValue fineval = f.eval_at_point(context,
3058  var_component,
3059  xyz_values[qp],
3060  system.time,
3061  false);
3062  // solution grad at the quadrature point
3063  typename GFunctor::FunctorValue finegrad;
3064  if (cont == C_ONE)
3065  finegrad = g->eval_at_point(context,
3066  var_component,
3067  xyz_values[qp],
3068  system.time,
3069  false);
3070 
3071  // Form edge projection matrix
3072  for (unsigned int sidei=0, freei=0;
3073  sidei != n_involved_dofs; ++sidei)
3074  {
3075  unsigned int i = involved_dofs[sidei];
3076  // fixed DoFs aren't test functions
3077  if (dof_is_fixed[sidei])
3078  continue;
3079  for (unsigned int sidej=0, freej=0;
3080  sidej != n_involved_dofs; ++sidej)
3081  {
3082  unsigned int j = involved_dofs[sidej];
3083  if (dof_is_fixed[sidej])
3084  Fe(freei) -= phi[i][qp] * phi[j][qp] *
3085  JxW[qp] * Uinvolved(sidej);
3086  else
3087  Ke(freei,freej) += phi[i][qp] *
3088  phi[j][qp] * JxW[qp];
3089  if (cont == C_ONE)
3090  {
3091  if (dof_is_fixed[sidej])
3092  Fe(freei) -= ( TensorTools::inner_product((*dphi)[i][qp],
3093  (*dphi)[j][qp]) ) *
3094  JxW[qp] * Uinvolved(sidej);
3095  else
3096  Ke(freei,freej) += ( TensorTools::inner_product((*dphi)[i][qp],
3097  (*dphi)[j][qp]) )
3098  * JxW[qp];
3099  }
3100  if (!dof_is_fixed[sidej])
3101  freej++;
3102  }
3103  Fe(freei) += phi[i][qp] * fineval * JxW[qp];
3104  if (cont == C_ONE)
3105  Fe(freei) += (TensorTools::inner_product(finegrad,
3106  (*dphi)[i][qp]) ) *
3107  JxW[qp];
3108  freei++;
3109  }
3110  }
3111 
3112  Ke.cholesky_solve(Fe, Ufree);
3113 
3114  // Transfer new edge solutions to element
3115  const processor_id_type pid = node ?
3116  node->processor_id() : DofObject::invalid_processor_id;
3117  insert_ids(free_dof_ids, Ufree.get_values(), pid);
3118 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
uint8_t processor_id_type
std::unordered_map< dof_id_type, typename FFunctor::ValuePushType > ids_to_save
void insert_ids(const std::vector< dof_id_type > &ids, const std::vector< InsertInput > &vals, processor_id_type pid)
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
template class LIBMESH_EXPORT DenseMatrix< Real >
Definition: dense_matrix.C:35
FEContinuity
defines an enum for finite element types to libmesh_assert a certain level (or type? Hcurl?) of continuity.
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
boostcopy::enable_if_c< ScalarTraits< T >::value &&ScalarTraits< T2 >::value, typename CompareTypes< T, T2 >::supertype >::type inner_product(const T &a, const T2 &b)
Definition: tensor_tools.h:51
uint8_t dof_id_type
Definition: id_types.h:67

◆ find_dofs_to_send()

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send ( const Node node,
const Elem elem,
unsigned short  node_num,
const var_set vars 
)
inherited

Definition at line 2839 of file generic_projector.h.

References libMesh::Elem::active(), libMesh::Variable::active_on_subdomain(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::Parallel::Utils::is_sorted(), libMesh::libmesh_assert(), mesh, libMesh::Elem::node_ptr(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Elem::subdomain_id(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::system, and libMesh::System::variable().

2840 {
2841  libmesh_assert (&node == elem.node_ptr(node_num));
2842 
2843  // Any ghosted node in our range might have an owner who needs our
2844  // data
2845  const processor_id_type owner = node.processor_id();
2846  if (owner != system.processor_id())
2847  {
2848  const MeshBase & mesh = system.get_mesh();
2849  const DofMap & dof_map = system.get_dof_map();
2850 
2851  // But let's check and see if we can be certain the owner can
2852  // compute any or all of its own dof coefficients on that node.
2853  std::vector<dof_id_type> node_dof_ids, patch_dof_ids;
2854  for (const auto & var : vars)
2855  {
2856  const Variable & variable = system.variable(var);
2857 
2858  if (!variable.active_on_subdomain(elem.subdomain_id()))
2859  continue;
2860 
2861  dof_map.dof_indices(elem, node_num, node_dof_ids, var);
2862  }
2863  libmesh_assert(std::is_sorted(node_dof_ids.begin(),
2864  node_dof_ids.end()));
2865  const std::vector<dof_id_type> & patch =
2866  (*this->projector.nodes_to_elem)[node.id()];
2867  for (const auto & elem_id : patch)
2868  {
2869  const Elem & patch_elem = mesh.elem_ref(elem_id);
2870  if (!patch_elem.active() || owner != patch_elem.processor_id())
2871  continue;
2872  dof_map.dof_indices(&patch_elem, patch_dof_ids);
2873  std::sort(patch_dof_ids.begin(), patch_dof_ids.end());
2874 
2875  // Remove any node_dof_ids that we see can be calculated on
2876  // this element
2877  std::vector<dof_id_type> diff_ids(node_dof_ids.size());
2878  auto it = std::set_difference(node_dof_ids.begin(), node_dof_ids.end(),
2879  patch_dof_ids.begin(), patch_dof_ids.end(), diff_ids.begin());
2880  diff_ids.resize(it-diff_ids.begin());
2881  node_dof_ids.swap(diff_ids);
2882  if (node_dof_ids.empty())
2883  break;
2884  }
2885 
2886  // Give ids_to_push default invalid pid: not yet computed
2887  for (auto id : node_dof_ids)
2889  }
2890 }
std::unordered_map< dof_id_type, std::pair< typename FFunctor::ValuePushType, processor_id_type > > new_ids_to_push
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
NodesToElemMap * nodes_to_elem
MeshBase & mesh
const MeshBase & get_mesh() const
Definition: system.h:2358
uint8_t processor_id_type
bool is_sorted(const std::vector< KeyType > &v)
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
libmesh_assert(ctx)
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ insert_id() [1/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_id ( dof_id_type  id,
const InsertInput &  val,
processor_id_type  pid 
)
inherited

Definition at line 1378 of file generic_projector.h.

1380 {
1381  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1382  "expected by the ProjectionAction");
1383 }

◆ insert_id() [2/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_id ( typename InsertInput  ,
typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type  = 0 
)

◆ insert_id() [3/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_id ( typename InsertInput  ,
typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type  = 0 
)

Definition at line 1378 of file generic_projector.h.

1380 {
1381  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1382  "expected by the ProjectionAction");
1383 }

◆ insert_ids() [1/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_ids ( const std::vector< dof_id_type > &  ids,
const std::vector< InsertInput > &  vals,
processor_id_type  pid 
)
inherited

Definition at line 1420 of file generic_projector.h.

1424 {
1425  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1426  "expected by the ProjectionAction");
1427 }

◆ insert_ids() [2/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_ids ( typename InsertInput  ,
typename std::enable_if< !std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type  = 0 
)

◆ insert_ids() [3/3]

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
template<typename InsertInput , typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type = 0>
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::insert_ids ( typename InsertInput  ,
typename std::enable_if< std::is_same< typename ProjectionAction::InsertInput, InsertInput >::value, int >::type  = 0 
)

Definition at line 1420 of file generic_projector.h.

1424 {
1425  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1426  "expected by the ProjectionAction");
1427 }

◆ join()

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::join ( const SubFunctor other)
inherited

Definition at line 1471 of file generic_projector.h.

References libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::new_ids_to_push, and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::new_ids_to_save.

Referenced by libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::join().

1472 {
1473  new_ids_to_push.insert(other.new_ids_to_push.begin(), other.new_ids_to_push.end());
1474  new_ids_to_save.insert(other.new_ids_to_save.begin(), other.new_ids_to_save.end());
1475 }
std::unordered_map< dof_id_type, std::pair< typename FFunctor::ValuePushType, processor_id_type > > new_ids_to_push
std::unordered_map< dof_id_type, typename FFunctor::ValuePushType > new_ids_to_save

◆ operator()()

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
void libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator() ( const node_range range)

Definition at line 2015 of file generic_projector.h.

References libMesh::C_ONE, libMesh::C_ZERO, dim, libMesh::Elem::dim(), libMesh::DISCONTINUOUS, libMesh::DofObject::dof_number(), libMesh::MeshBase::elem_ref(), libMesh::FEInterface::extra_hanging_dofs(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::Elem::get_node_index(), libMesh::HERMITE, libMesh::Elem::hmin(), libMesh::DofObject::id(), libMesh::index_range(), int, libMesh::Elem::is_vertex_on_parent(), libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::DofObject::n_comp(), libMesh::FEInterface::n_dofs_at_node(), libMesh::System::number(), libMesh::Elem::parent(), libMesh::Elem::point(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::Elem::refinement_flag(), libMesh::SCALAR, libMesh::SIDE_DISCONTINUOUS, libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::system, libMesh::System::time, libMesh::TOLERANCE, libMesh::Variable::type(), libMesh::TYPE_VECTOR, libMesh::System::variable(), libMesh::System::variable_scalar_number(), and libMesh::Elem::which_child_am_i().

2016 {
2017  LOG_SCOPE ("project_vertices","GenericProjector");
2018 
2019  const unsigned int sys_num = system.number();
2020 
2021  // Variables with extra hanging dofs can't safely use eval_at_node
2022  // in as many places as variables without can.
2023  std::vector<unsigned short> extra_hanging_dofs;
2024  for (auto v_num : this->projector.variables)
2025  {
2026  if (extra_hanging_dofs.size() <= v_num)
2027  extra_hanging_dofs.resize(v_num+1, false);
2028  extra_hanging_dofs[v_num] =
2030  }
2031 
2032  for (const auto & v_pair : range)
2033  {
2034  const Node & vertex = *v_pair.first;
2035  const Elem & elem = *std::get<0>(v_pair.second);
2036  const unsigned int n = std::get<1>(v_pair.second);
2037  const var_set & vertex_vars = std::get<2>(v_pair.second);
2038 
2039  context.pre_fe_reinit(system, &elem);
2040 
2041  this->find_dofs_to_send(vertex, elem, n, vertex_vars);
2042 
2043  // Look at all the variables we're supposed to interpolate from
2044  // this element on this vertex
2045  for (const auto & var : vertex_vars)
2046  {
2047  const Variable & variable = system.variable(var);
2048  const FEType & base_fe_type = variable.type();
2049  const unsigned int var_component =
2051 
2052  if (base_fe_type.family == SCALAR)
2053  continue;
2054 
2055  const FEContinuity cont = this->conts[var];
2056  const FEFieldType field_type = this->field_types[var];
2057 
2058  if (cont == DISCONTINUOUS)
2059  {
2060  libmesh_assert_equal_to(vertex.n_comp(sys_num, var), 0);
2061  }
2062  else if (cont == C_ZERO ||
2063  cont == SIDE_DISCONTINUOUS)
2064  {
2065  if (cont == SIDE_DISCONTINUOUS &&
2066  elem.dim() != 1)
2067  {
2068  libmesh_assert_equal_to(vertex.n_comp(sys_num, var), 0);
2069  continue;
2070  }
2071 
2072  const FValue val = f.eval_at_node
2073  (context, var_component, /*dim=*/ 0, // Don't care w/C0
2074  vertex, extra_hanging_dofs[var], system.time);
2075 
2076  if (field_type == TYPE_VECTOR)
2077  {
2078  libmesh_assert_equal_to(vertex.n_comp(sys_num, var), elem.dim());
2079 
2080  // We will have a number of nodal value DoFs equal to the elem dim
2081  for (auto i : make_range(elem.dim()))
2082  {
2083  const dof_id_type id = vertex.dof_number(sys_num, var, i);
2084 
2085  // Need this conversion so that this method
2086  // will compile for TYPE_SCALAR instantiations
2087  const auto insert_val =
2088  raw_value<typename ProjectionAction::InsertInput>(val, i);
2089 
2090  insert_id(id, insert_val, vertex.processor_id());
2091  }
2092  }
2093  else
2094  {
2095  // C_ZERO elements have a single nodal value DoF at
2096  // vertices. We can't assert n_comp==1 here,
2097  // because if this is a hanging node then it may have
2098  // more face/edge DoFs, but we don't need to deal with
2099  // those here.
2100 
2101  const dof_id_type id = vertex.dof_number(sys_num, var, 0);
2102  insert_id(id, val, vertex.processor_id());
2103  }
2104  }
2105  else if (cont == C_ONE)
2106  {
2107  libmesh_assert(vertex.n_comp(sys_num, var));
2108  const dof_id_type first_id = vertex.dof_number(sys_num, var, 0);
2109 
2110  // C_ONE elements have a single nodal value and dim
2111  // gradient values at vertices, as well as cross
2112  // gradients for HERMITE. We need to have an element in
2113  // hand to figure out dim and to have in case this
2114  // vertex is a new vertex.
2115  const int dim = elem.dim();
2116 #ifndef NDEBUG
2117  // For now all C1 elements at a vertex had better have
2118  // the same dimension. If anyone hits these asserts let
2119  // me know; we could probably support a mixed-dimension
2120  // mesh IFF the 2D elements were all parallel to xy and
2121  // the 1D elements all parallel to x.
2122  for (const auto e_id : (*this->projector.nodes_to_elem)[vertex.id()])
2123  {
2124  const Elem & e = system.get_mesh().elem_ref(e_id);
2125  libmesh_assert_equal_to(dim, e.dim());
2126  }
2127 #endif
2128 #ifdef LIBMESH_ENABLE_AMR
2129  bool is_old_vertex = true;
2130  if (elem.refinement_flag() == Elem::JUST_REFINED)
2131  {
2132  const int i_am_child =
2133  elem.parent()->which_child_am_i(&elem);
2134  is_old_vertex =
2135  elem.parent()->is_vertex_on_parent(i_am_child, n);
2136  }
2137 #else
2138  const bool is_old_vertex = false;
2139 #endif
2140 
2141  // The hermite element vertex shape functions are weird
2142  if (base_fe_type.family == HERMITE)
2143  {
2144  const FValue val =
2145  f.eval_at_node(context,
2146  var_component,
2147  dim,
2148  vertex,
2149  extra_hanging_dofs[var],
2150  system.time);
2151  insert_id(first_id, val, vertex.processor_id());
2152 
2153  typename GFunctor::FunctorValue grad =
2154  is_old_vertex ?
2155  g->eval_at_node(context,
2156  var_component,
2157  dim,
2158  vertex,
2159  extra_hanging_dofs[var],
2160  system.time) :
2161  g->eval_at_point(context,
2162  var_component,
2163  vertex,
2164  system.time,
2165  false);
2166  // x derivative. Use slice because grad may be a tensor type
2167  insert_id(first_id+1, grad.slice(0),
2168  vertex.processor_id());
2169 #if LIBMESH_DIM > 1
2170  if (dim > 1 && is_old_vertex && f.is_grid_projection())
2171  {
2172  for (int i = 1; i < dim; ++i)
2173  insert_id(first_id+i+1, grad.slice(i),
2174  vertex.processor_id());
2175 
2176  // We can directly copy everything else too
2177  std::vector<FValue> derivs;
2178  f.eval_mixed_derivatives
2179  (context, var_component, dim, vertex, derivs);
2180  for (auto i : index_range(derivs))
2181  insert_id(first_id+dim+1+i, derivs[i],
2182  vertex.processor_id());
2183  }
2184  else if (dim > 1)
2185  {
2186  // We'll finite difference mixed derivatives.
2187  // This delta_x used to be TOLERANCE*hmin, but
2188  // the factor of 10 improved the accuracy in
2189  // some unit test projections
2190  Real delta_x = TOLERANCE * 10 * elem.hmin();
2191 
2192  Point nxminus = elem.point(n),
2193  nxplus = elem.point(n);
2194  nxminus(0) -= delta_x;
2195  nxplus(0) += delta_x;
2196  typename GFunctor::FunctorValue gxminus =
2197  g->eval_at_point(context,
2198  var_component,
2199  nxminus,
2200  system.time,
2201  true);
2202  typename GFunctor::FunctorValue gxplus =
2203  g->eval_at_point(context,
2204  var_component,
2205  nxplus,
2206  system.time,
2207  true);
2208  // y derivative
2209  insert_id(first_id+2, grad.slice(1),
2210  vertex.processor_id());
2211  // xy derivative
2212  insert_id(first_id+3,
2213  (grad_component(gxplus, 1) - grad_component(gxminus, 1)) / 2. / delta_x,
2214  vertex.processor_id());
2215 
2216 #if LIBMESH_DIM > 2
2217  if (dim > 2)
2218  {
2219  // z derivative
2220  insert_id(first_id+4, grad.slice(2),
2221  vertex.processor_id());
2222  // xz derivative
2223  insert_id(first_id+5,
2224  (grad_component(gxplus, 2) - grad_component(gxminus, 2)) / 2. / delta_x,
2225  vertex.processor_id());
2226 
2227  // We need new points for yz
2228  Point nyminus = elem.point(n),
2229  nyplus = elem.point(n);
2230  nyminus(1) -= delta_x;
2231  nyplus(1) += delta_x;
2232  typename GFunctor::FunctorValue gyminus =
2233  g->eval_at_point(context,
2234  var_component,
2235  nyminus,
2236  system.time,
2237  true);
2238  typename GFunctor::FunctorValue gyplus =
2239  g->eval_at_point(context,
2240  var_component,
2241  nyplus,
2242  system.time,
2243  true);
2244  // yz derivative
2245  insert_id(first_id+6,
2246  (grad_component(gyplus, 2) - grad_component(gyminus, 2)) / 2. / delta_x,
2247  vertex.processor_id());
2248  // Getting a 2nd order xyz is more tedious
2249  Point nxmym = elem.point(n),
2250  nxmyp = elem.point(n),
2251  nxpym = elem.point(n),
2252  nxpyp = elem.point(n);
2253  nxmym(0) -= delta_x;
2254  nxmym(1) -= delta_x;
2255  nxmyp(0) -= delta_x;
2256  nxmyp(1) += delta_x;
2257  nxpym(0) += delta_x;
2258  nxpym(1) -= delta_x;
2259  nxpyp(0) += delta_x;
2260  nxpyp(1) += delta_x;
2261  typename GFunctor::FunctorValue gxmym =
2262  g->eval_at_point(context,
2263  var_component,
2264  nxmym,
2265  system.time,
2266  true);
2267  typename GFunctor::FunctorValue gxmyp =
2268  g->eval_at_point(context,
2269  var_component,
2270  nxmyp,
2271  system.time,
2272  true);
2273  typename GFunctor::FunctorValue gxpym =
2274  g->eval_at_point(context,
2275  var_component,
2276  nxpym,
2277  system.time,
2278  true);
2279  typename GFunctor::FunctorValue gxpyp =
2280  g->eval_at_point(context,
2281  var_component,
2282  nxpyp,
2283  system.time,
2284  true);
2285  FValue gxzplus = (grad_component(gxpyp, 2) - grad_component(gxmyp, 2))
2286  / 2. / delta_x;
2287  FValue gxzminus = (grad_component(gxpym, 2) - grad_component(gxmym, 2))
2288  / 2. / delta_x;
2289  // xyz derivative
2290  insert_id(first_id+7,
2291  (gxzplus - gxzminus) / 2. / delta_x,
2292  vertex.processor_id());
2293  }
2294 #endif // LIBMESH_DIM > 2
2295  }
2296 #endif // LIBMESH_DIM > 1
2297  }
2298  else
2299  {
2300  // Currently other C_ONE elements have a single nodal
2301  // value shape function and nodal gradient component
2302  // shape functions
2303  libmesh_assert_equal_to(
2305  base_fe_type,
2306  &elem,
2307  elem.get_node_index(&vertex),
2310  (unsigned int)(1 + dim));
2311 
2312  const FValue val =
2313  f.eval_at_node(context, var_component, dim,
2314  vertex, extra_hanging_dofs[var],
2315  system.time);
2316  insert_id(first_id, val, vertex.processor_id());
2317  typename GFunctor::FunctorValue grad =
2318  is_old_vertex ?
2319  g->eval_at_node(context, var_component, dim,
2320  vertex, extra_hanging_dofs[var],
2321  system.time) :
2322  g->eval_at_point(context, var_component, vertex,
2323  system.time, false);
2324  for (int i=0; i!= dim; ++i)
2325  insert_id(first_id + i + 1, grad.slice(i),
2326  vertex.processor_id());
2327  }
2328  }
2329  else
2330  libmesh_error_msg("Unknown continuity " << cont);
2331  }
2332  }
2333 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
const Elem * parent() const
Definition: elem.h:3030
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2489
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
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
NodesToElemMap * nodes_to_elem
static constexpr Real TOLERANCE
unsigned int dim
void should_p_refine(unsigned int g, bool p_refine)
Describe whether the given variable group should be p-refined.
Definition: dof_map.h:2402
const MeshBase & get_mesh() const
Definition: system.h:2358
void insert_id(dof_id_type id, const InsertInput &val, processor_id_type pid)
unsigned int var_group_from_var_number(unsigned int var_num) const
Definition: dof_map.h:2430
unsigned int number() const
Definition: system.h:2350
static bool extra_hanging_dofs(const FEType &fe_t)
libmesh_assert(ctx)
std::vector< FEFieldType > field_types
const std::vector< unsigned int > & variables
unsigned int which_child_am_i(const Elem *e) const
Definition: elem.h:3192
static unsigned int n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
Definition: fe_interface.C:436
void find_dofs_to_send(const Node &node, const Elem &elem, unsigned short node_num, const var_set &vars)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEContinuity
defines an enum for finite element types to libmesh_assert a certain level (or type? Hcurl?) of continuity.
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:639
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
std::set< unsigned int > var_set
const DofMap & get_dof_map() const
Definition: system.h:2374
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
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
std::vector< FEContinuity > conts
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:144
FEFieldType
defines an enum for finite element field types - i.e.

Member Data Documentation

◆ action

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
ProjectionAction libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::action

Definition at line 231 of file generic_projector.h.

◆ context

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
FEMContext libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::context

Definition at line 236 of file generic_projector.h.

◆ conts

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
std::vector<FEContinuity> libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::conts

Definition at line 239 of file generic_projector.h.

◆ f

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
FFunctor libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::f

Definition at line 232 of file generic_projector.h.

◆ field_types

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
std::vector<FEFieldType> libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::field_types

Definition at line 240 of file generic_projector.h.

◆ g

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
std::unique_ptr<GFunctor> libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::g

Definition at line 267 of file generic_projector.h.

◆ new_ids_to_push

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
std::unordered_map<dof_id_type, std::pair<typename FFunctor::ValuePushType, processor_id_type> > libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::new_ids_to_push
inherited

◆ new_ids_to_save

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
std::unordered_map<dof_id_type, typename FFunctor::ValuePushType> libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::new_ids_to_save
inherited

◆ projector

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
GenericProjector& libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::projector
inherited

Definition at line 170 of file generic_projector.h.

◆ system

template<typename FFunctor , typename GFunctor , typename FValue , typename ProjectionAction >
const System& libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::system

Definition at line 242 of file generic_projector.h.


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