9#ifndef __COMMINTERFACE_HPP__
10#define __COMMINTERFACE_HPP__
28 static std::map<moab::Core *, boost::weak_ptr<ParallelComm>> pcomm_map;
33 auto *mesh_ptr = core_mesh_ptr;
34 auto &pcomm_map =
getMap();
36 if (
auto it = pcomm_map.find(mesh_ptr);
it != pcomm_map.end()) {
37 if (
auto pcomm_ptr =
it->second.lock())
41 if (
auto *raw_pcomm = ParallelComm::get_pcomm(mesh_ptr,
MYPCOMM_INDEX)) {
42 auto pcomm_ptr = boost::shared_ptr<ParallelComm>(
43 raw_pcomm, [mesh_ptr](ParallelComm *) {});
44 pcomm_map[mesh_ptr] = pcomm_ptr;
48 auto pcomm_ptr = boost::shared_ptr<ParallelComm>(
49 new ParallelComm(mesh_ptr, PETSC_COMM_WORLD),
50 [mesh_ptr](ParallelComm *pcomm) {
58 static auto getOrCreate(
const boost::shared_ptr<moab::Core> &core_mesh_ptr) {
70 inline static bool debug =
false;
71 inline static Sev sev = Sev::verbose;
161 const Range &child_entities);
175 const Range &preserve = {});
197 int complete_mesh_rank = -1);
228 const std::string &fe_name,
255 const std::string &fe_name,
272 const int num_entities,
273 const int owner_proc = 0,
287 const int owner_proc = 0,
301 const int owner_proc = 0,
347 std::map<int, Range> *received_ents,
410 const int adj_dim,
const int n_parts,
411 Tag *th_vertex_weights =
nullptr,
412 Tag *th_edge_weights =
nullptr,
413 Tag *th_part_weights =
nullptr,
415 const bool preserve_vertex_ids =
false);
424 std::array<Range, 4> &&, std::vector<const CubitMeshSets *> &&)>;
426 static std::array<Range, 4>
428 std::vector<const CubitMeshSets *> &&) {
429 return proc_ents_skin;
443 moab::Interface &moab,
const char *file_name,
int dim,
445 const char *options =
"PARALLEL=BCAST;PARTITION=");
510 const int nb_coeffs,
Sev sev = Sev::verbose,
511 int root_rank = 0,
bool get_vertices =
true);
536 const int nb_coeffs,
Sev sev = Sev::verbose,
545 CHKERR VecGhostUpdateBegin(
v, ADD_VALUES, SCATTER_REVERSE);
546 CHKERR VecGhostUpdateEnd(
v, ADD_VALUES, SCATTER_REVERSE);
547 CHKERR VecGhostUpdateBegin(
v, INSERT_VALUES, SCATTER_FORWARD);
548 CHKERR VecGhostUpdateEnd(
v, INSERT_VALUES, SCATTER_FORWARD);
std::vector< Cell > cells
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
MoFEMErrorCode synchroniseFieldEntities(const std::string name, int verb=DEFAULT_VERBOSITY)
SeverityLevel
Severity levels.
MoFEMErrorCode partitionMesh(const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false, const bool preserve_vertex_ids=false)
Set partition tag to each finite element in the problem.
MoFEMErrorCode resolveSharedFiniteElements(const Problem *problem_ptr, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
resolve shared entities for finite elements in the problem
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
constexpr auto field_name
static MoFEMErrorCode updateEntitiesPetscVector(moab::Interface &moab, EntitiesPetscVector &vec, Tag tag, UpdateGhosts update_gosts=defaultUpdateGhosts)
Exchange data between vector and data.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
std::function< MoFEMErrorCode(Vec vec)> UpdateGhosts
MoFEMErrorCode inheritPartitions(const Range &source_entities, const Range &child_entities)
static Range getPartEntities(moab::Interface &moab, int part)
~CommInterface()=default
Destructor.
MoFEMErrorCode synchroniseByConnectivity(const Range &entities, int complete_mesh_rank=-1)
MoFEMErrorCode retainPartition(Range &entities, const BitRefLevel &active_bit, const Range &preserve={})
static MoFEMErrorCode defaultUpdateGhosts(Vec v)
MoFEMErrorCode makeEntitiesMultishared(const EntityHandle *entities, const int num_entities, const int owner_proc=0, int verb=DEFAULT_VERBOSITY)
make entities from proc 0 shared on all proc
static std::array< Range, 4 > defaultProcSkinFun(std::array< Range, 4 > &&proc_ents_skin, std::vector< const CubitMeshSets * > &&)
static MoFEMErrorCode loadFileRootProcAllRestDistributed(moab::Interface &moab, const char *file_name, int dim, LoadFileFun proc_skin_fun=defaultProcSkinFun, const char *options="PARALLEL=BCAST;PARTITION=")
Root proc has whole mesh, other procs only part of it.
MoFEMErrorCode synchroniseEntities(Range &ent, std::map< int, Range > *received_ents, int verb=DEFAULT_VERBOSITY)
synchronize entity range on processors (collective)
MoFEMErrorCode synchroniseByParentChild(const BitRefLevel &parent_bit, const BitRefLevel &child_bit, int verb=DEFAULT_VERBOSITY)
std::function< std::array< Range, 4 >(std::array< Range, 4 > &&, std::vector< const CubitMeshSets * > &&)> LoadFileFun
static MoFEMErrorCode setVectorFromTag(moab::Interface &moab, EntitiesPetscVector &vec, Tag tag)
Set the Vector From Tag object.
static MoFEMErrorCode removeMeshsetFromPartition(moab::Interface &moab, const EntityHandle meshset, const int pcomm_id=MYPCOMM_INDEX)
Remove a meshset from all partition sets before it is deleted.
static MoFEMErrorCode setTagFromVector(moab::Interface &moab, EntitiesPetscVector &vec, Tag tag)
Set the Tag From Vector object.
MoFEMErrorCode makeFieldEntitiesMultishared(const std::string field_name, const int owner_proc=0, int verb=DEFAULT_VERBOSITY)
make field entities multi shared
std::pair< std::pair< Range, Range >, SmartPetscObj< Vec > > EntitiesPetscVector
MoFEMErrorCode resolveParentEntities(const Range &ent, int verb=DEFAULT_VERBOSITY)
Synchronise parent entities.
MoFEMErrorCode gatherMesh(const Range &cells, TetMeshData &data, int root=0)
MoFEMErrorCode exchangeFieldData(const std::string field_name, int verb=DEFAULT_VERBOSITY)
Exchange field data.
static EntitiesPetscVector createEntitiesPetscVector(MPI_Comm comm, moab::Interface &moab, std::function< Range(Range)> get_entities_fun, const int nb_coeffs, Sev sev=Sev::verbose, int root_rank=0, bool get_vertices=true)
Create a ghost vector for exchanging data.
MoFEMErrorCode broadcastMesh(TetMeshData &data, int root=0)
static auto getOrCreate(const boost::shared_ptr< moab::Core > &core_mesh_ptr)
static auto getOrCreate(moab::Core *core_mesh_ptr)
keeps basic data about problem
intrusive_ptr for managing petsc objects
base class for all interface classes