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 253 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 1357 of file generic_projector.h.

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

1357  :
1358  SubFunctor(p)
1359 {
1360 
1361  // Our C1 elements need gradient information
1362  for (const auto & var : this->projector.variables)
1363  if (this->conts[var] == C_ONE)
1364  {
1365  libmesh_assert(p.master_g);
1366  g = std::make_unique<GFunctor>(*p.master_g);
1367  g->init_context(context);
1368  return;
1369  }
1370 }
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 3004 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.

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

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

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

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

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
protected

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: