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

#include <generic_projector.h>

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

Public Member Functions

 SubProjector (GenericProjector &p)
 
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)
 
void find_dofs_to_send (const Node &node, const Elem &elem, unsigned short node_num, const var_set &vars)
 
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 join (const SubFunctor &other)
 

Public Attributes

ProjectionAction action
 
FFunctor f
 
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)
 

Protected Attributes

std::unique_ptr< GFunctor > g
 

Detailed Description

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

Definition at line 240 of file generic_projector.h.

Constructor & Destructor Documentation

◆ SubProjector()

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

Definition at line 1344 of file generic_projector.h.

References libMesh::C_ONE, libMesh::libmesh_assert(), and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::master_g.

1344  :
1345  SubFunctor(p)
1346 {
1347 
1348  // Our C1 elements need gradient information
1349  for (const auto & var : this->projector.variables)
1350  if (this->conts[var] == C_ONE)
1351  {
1352  libmesh_assert(p.master_g);
1353  g = std::make_unique<GFunctor>(*p.master_g);
1354  g->init_context(context);
1355  return;
1356  }
1357 }
libmesh_assert(ctx)
const std::vector< unsigned int > & variables
std::vector< FEContinuity > conts

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

Definition at line 2988 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.

2993 {
2994  const auto & JxW = fe.get_JxW();
2995  const auto & phi = fe.get_phi();
2996  const std::vector<std::vector<typename FEGenericBase<typename FFunctor::RealType>::OutputGradient>> * dphi = nullptr;
2997  const std::vector<Point> & xyz_values = fe.get_xyz();
2998  const FEContinuity cont = fe.get_continuity();
2999  const std::unordered_map<dof_id_type, typename FFunctor::ValuePushType> & ids_to_save =
3000  this->projector.ids_to_save;
3001 
3002  if (cont == C_ONE)
3003  dphi = &(fe.get_dphi());
3004 
3005  const unsigned int n_involved_dofs =
3006  cast_int<unsigned int>(involved_dofs.size());
3007 
3008  std::vector<dof_id_type> free_dof_ids;
3009  DenseVector<typename FFunctor::ValuePushType> Uinvolved(n_involved_dofs);
3010  std::vector<char> dof_is_fixed(n_involved_dofs, false); // bools
3011 
3012  for (auto i : make_range(n_involved_dofs))
3013  {
3014  const dof_id_type id = dof_indices_var[involved_dofs[i]];
3015  auto iter = ids_to_save.find(id);
3016  if (iter == ids_to_save.end())
3017  free_dof_ids.push_back(id);
3018  else
3019  {
3020  dof_is_fixed[i] = true;
3021  Uinvolved(i) = iter->second;
3022  }
3023  }
3024 
3025  const unsigned int free_dofs = free_dof_ids.size();
3026 
3027  // There may be nothing to project
3028  if (!free_dofs)
3029  return;
3030 
3031  // The element matrix and RHS for projections.
3032  // Note that Ke is always real-valued, whereas
3033  // Fe may be complex valued if complex number
3034  // support is enabled
3035  DenseMatrix<Real> Ke(free_dofs, free_dofs);
3036  DenseVector<typename FFunctor::ValuePushType> Fe(free_dofs);
3037  // The new degree of freedom coefficients to solve for
3038  DenseVector<typename FFunctor::ValuePushType> Ufree(free_dofs);
3039 
3040  const unsigned int n_qp =
3041  cast_int<unsigned int>(xyz_values.size());
3042 
3043  // Loop over the quadrature points
3044  for (unsigned int qp=0; qp<n_qp; qp++)
3045  {
3046  // solution at the quadrature point
3047  FValue fineval = f.eval_at_point(context,
3048  var_component,
3049  xyz_values[qp],
3050  system.time,
3051  false);
3052  // solution grad at the quadrature point
3053  typename GFunctor::FunctorValue finegrad;
3054  if (cont == C_ONE)
3055  finegrad = g->eval_at_point(context,
3056  var_component,
3057  xyz_values[qp],
3058  system.time,
3059  false);
3060 
3061  // Form edge projection matrix
3062  for (unsigned int sidei=0, freei=0;
3063  sidei != n_involved_dofs; ++sidei)
3064  {
3065  unsigned int i = involved_dofs[sidei];
3066  // fixed DoFs aren't test functions
3067  if (dof_is_fixed[sidei])
3068  continue;
3069  for (unsigned int sidej=0, freej=0;
3070  sidej != n_involved_dofs; ++sidej)
3071  {
3072  unsigned int j = involved_dofs[sidej];
3073  if (dof_is_fixed[sidej])
3074  Fe(freei) -= phi[i][qp] * phi[j][qp] *
3075  JxW[qp] * Uinvolved(sidej);
3076  else
3077  Ke(freei,freej) += phi[i][qp] *
3078  phi[j][qp] * JxW[qp];
3079  if (cont == C_ONE)
3080  {
3081  if (dof_is_fixed[sidej])
3082  Fe(freei) -= ( TensorTools::inner_product((*dphi)[i][qp],
3083  (*dphi)[j][qp]) ) *
3084  JxW[qp] * Uinvolved(sidej);
3085  else
3086  Ke(freei,freej) += ( TensorTools::inner_product((*dphi)[i][qp],
3087  (*dphi)[j][qp]) )
3088  * JxW[qp];
3089  }
3090  if (!dof_is_fixed[sidej])
3091  freej++;
3092  }
3093  Fe(freei) += phi[i][qp] * fineval * JxW[qp];
3094  if (cont == C_ONE)
3095  Fe(freei) += (TensorTools::inner_product(finegrad,
3096  (*dphi)[i][qp]) ) *
3097  JxW[qp];
3098  freei++;
3099  }
3100  }
3101 
3102  Ke.cholesky_solve(Fe, Ufree);
3103 
3104  // Transfer new edge solutions to element
3105  const processor_id_type pid = node ?
3106  node->processor_id() : DofObject::invalid_processor_id;
3107  insert_ids(free_dof_ids, Ufree.get_values(), pid);
3108 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1595
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:488
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:134
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 2829 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().

2830 {
2831  libmesh_assert (&node == elem.node_ptr(node_num));
2832 
2833  // Any ghosted node in our range might have an owner who needs our
2834  // data
2835  const processor_id_type owner = node.processor_id();
2836  if (owner != system.processor_id())
2837  {
2838  const MeshBase & mesh = system.get_mesh();
2839  const DofMap & dof_map = system.get_dof_map();
2840 
2841  // But let's check and see if we can be certain the owner can
2842  // compute any or all of its own dof coefficients on that node.
2843  std::vector<dof_id_type> node_dof_ids, patch_dof_ids;
2844  for (const auto & var : vars)
2845  {
2846  const Variable & variable = system.variable(var);
2847 
2848  if (!variable.active_on_subdomain(elem.subdomain_id()))
2849  continue;
2850 
2851  dof_map.dof_indices(elem, node_num, node_dof_ids, var);
2852  }
2853  libmesh_assert(std::is_sorted(node_dof_ids.begin(),
2854  node_dof_ids.end()));
2855  const std::vector<dof_id_type> & patch =
2856  (*this->projector.nodes_to_elem)[node.id()];
2857  for (const auto & elem_id : patch)
2858  {
2859  const Elem & patch_elem = mesh.elem_ref(elem_id);
2860  if (!patch_elem.active() || owner != patch_elem.processor_id())
2861  continue;
2862  dof_map.dof_indices(&patch_elem, patch_dof_ids);
2863  std::sort(patch_dof_ids.begin(), patch_dof_ids.end());
2864 
2865  // Remove any node_dof_ids that we see can be calculated on
2866  // this element
2867  std::vector<dof_id_type> diff_ids(node_dof_ids.size());
2868  auto it = std::set_difference(node_dof_ids.begin(), node_dof_ids.end(),
2869  patch_dof_ids.begin(), patch_dof_ids.end(), diff_ids.begin());
2870  diff_ids.resize(it-diff_ids.begin());
2871  node_dof_ids.swap(diff_ids);
2872  if (node_dof_ids.empty())
2873  break;
2874  }
2875 
2876  // Give ids_to_push default invalid pid: not yet computed
2877  for (auto id : node_dof_ids)
2879  }
2880 }
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:2377
MeshBase & mesh
const MeshBase & get_mesh() const
Definition: system.h:2277
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:488
libmesh_assert(ctx)
std::unordered_map< dof_id_type, std::vector< dof_id_type > > * nodes_to_elem
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

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

1367 {
1368  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1369  "expected by the ProjectionAction");
1370 }

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

Definition at line 1365 of file generic_projector.h.

1367 {
1368  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1369  "expected by the ProjectionAction");
1370 }

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

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

1411 {
1412  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1413  "expected by the ProjectionAction");
1414 }

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

1411 {
1412  libmesh_error_msg("ID insertion should only occur when the provided input matches that "
1413  "expected by the ProjectionAction");
1414 }

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

1459 {
1460  new_ids_to_push.insert(other.new_ids_to_push.begin(), other.new_ids_to_push.end());
1461  new_ids_to_save.insert(other.new_ids_to_save.begin(), other.new_ids_to_save.end());
1462 }
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

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 218 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 223 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 226 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 219 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 227 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
protected

Definition at line 254 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 157 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 229 of file generic_projector.h.


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