libMesh
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor Struct Reference

#include <generic_projector.h>

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

Public Member Functions

 SubFunctor (GenericProjector &p)
 
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_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 join (const SubFunctor &other)
 

Public Attributes

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 Attributes

ProjectionAction action
 
FFunctor f
 
FEMContext context
 
std::vector< FEContinuityconts
 
std::vector< FEFieldTypefield_types
 
const Systemsystem
 

Detailed Description

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

Definition at line 169 of file generic_projector.h.

Constructor & Destructor Documentation

◆ SubFunctor()

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

Definition at line 1285 of file generic_projector.h.

1286 :
1287 projector(p),
1288 action(p.master_action),
1289 f(p.master_f),
1290 context(p.system, &p.variables, /* allocate_local_matrices= */ false),
1291 conts(p.system.n_vars()),
1292 field_types(p.system.n_vars()), system(p.system)
1293{
1294 // Loop over all the variables we've been requested to project, to
1295 // pre-request
1296 for (const auto & var : this->projector.variables)
1297 {
1298 // FIXME: Need to generalize this to vector-valued elements. [PB]
1299 FEAbstract * fe = nullptr;
1300 FEAbstract * side_fe = nullptr;
1301 FEAbstract * edge_fe = nullptr;
1302
1303 const std::set<unsigned char> & elem_dims =
1305
1306 for (const auto & dim : elem_dims)
1307 {
1308 context.get_element_fe( var, fe, dim );
1309 if (fe->get_fe_type().family == SCALAR)
1310 continue;
1311 if (dim > 1)
1312 context.get_side_fe( var, side_fe, dim );
1313 if (dim > 2)
1314 context.get_edge_fe( var, edge_fe );
1315
1316 fe->get_JxW();
1317 fe->get_xyz();
1318 fe->get_JxW();
1319
1320 fe->request_phi();
1321 if (dim > 1)
1322 {
1323 side_fe->get_JxW();
1324 side_fe->get_xyz();
1325 side_fe->request_phi();
1326 }
1327 if (dim > 2)
1328 {
1329 edge_fe->get_JxW();
1330 edge_fe->get_xyz();
1331 edge_fe->request_phi();
1332 }
1333
1334 const FEContinuity cont = fe->get_continuity();
1335 this->conts[var] = cont;
1336 if (cont == C_ONE)
1337 {
1338 fe->request_dphi();
1339 if (dim > 1)
1340 side_fe->request_dphi();
1341 if (dim > 2)
1342 edge_fe->request_dphi();
1343 }
1344
1345 this->field_types[var] = FEInterface::field_type(fe->get_fe_type());
1346 }
1347 }
1348
1349 // Now initialize any user requested shape functions, xyz vals, etc
1350 f.init_context(context);
1351}
unsigned int dim
static FEFieldType field_type(const FEType &fe_type)
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
const std::set< unsigned char > & elem_dimensions() const
void get_edge_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge (3D only!) finite element object for variable var.
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
const std::vector< unsigned int > & variables
std::vector< FEFieldType > field_types

References libMesh::C_ONE, libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::context, libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::conts, dim, libMesh::FEMContext::elem_dimensions(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::f, libMesh::FEType::family, libMesh::FEInterface::field_type(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::field_types, libMesh::FEAbstract::get_continuity(), libMesh::FEMContext::get_edge_fe(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_fe_type(), libMesh::FEAbstract::get_JxW(), libMesh::FEMContext::get_side_fe(), libMesh::FEAbstract::get_xyz(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::projector, libMesh::FEAbstract::request_dphi(), libMesh::FEAbstract::request_phi(), libMesh::SCALAR, and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::variables.

Member Function Documentation

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

Definition at line 2844 of file generic_projector.h.

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)
2894 new_ids_to_push[id].second = DofObject::invalid_processor_id;
2895 }
2896}
processor_id_type processor_id() const
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition system.C:2704
const DofMap & get_dof_map() const
Definition system.h:2417
const MeshBase & get_mesh() const
Definition system.h:2401
MeshBase & mesh
libmesh_assert(ctx)
uint8_t processor_id_type
Definition id_types.h:104
std::unordered_map< dof_id_type, std::pair< typename FFunctor::ValuePushType, processor_id_type > > new_ids_to_push

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::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::Elem::subdomain_id(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::system, and libMesh::System::variable().

◆ insert_id() [1/2]

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 
)

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/2]

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 ( dof_id_type  id,
const InsertInput &  val,
processor_id_type  pid 
)

◆ insert_ids() [1/2]

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 
)

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/2]

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 ( const std::vector< dof_id_type > &  ids,
const std::vector< InsertInput > &  vals,
processor_id_type  pid 
)

◆ join()

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

Definition at line 1470 of file generic_projector.h.

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, typename FFunctor::ValuePushType > new_ids_to_save

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

Member Data Documentation

◆ action

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

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
protected

◆ conts

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

◆ f

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

◆ field_types

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

◆ 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

◆ 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

◆ projector

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

◆ system

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

Definition at line 242 of file generic_projector.h.


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