9#ifndef __COMMINTERFACE_HPP__
10#define __COMMINTERFACE_HPP__
19 static std::map<moab::Core *, boost::weak_ptr<ParallelComm>> pcomm_map;
24 auto *mesh_ptr = core_mesh_ptr;
25 auto &pcomm_map =
getMap();
27 if (
auto it = pcomm_map.find(mesh_ptr); it != pcomm_map.end()) {
28 if (
auto pcomm_ptr = it->second.lock())
32 if (
auto *raw_pcomm = ParallelComm::get_pcomm(mesh_ptr,
MYPCOMM_INDEX)) {
33 auto pcomm_ptr = boost::shared_ptr<ParallelComm>(
34 raw_pcomm, [mesh_ptr](ParallelComm *pcomm) {});
35 pcomm_map[mesh_ptr] = pcomm_ptr;
39 auto pcomm_ptr = boost::shared_ptr<ParallelComm>(
40 new ParallelComm(mesh_ptr, PETSC_COMM_WORLD),
41 [mesh_ptr](ParallelComm *pcomm) {
49 static auto getOrCreate(
const boost::shared_ptr<moab::Core> &core_mesh_ptr) {
61 inline static bool debug =
false;
62 inline static Sev sev = Sev::verbose;
104 const std::string &fe_name,
131 const std::string &fe_name,
148 const int num_entities,
149 const int owner_proc = 0,
163 const int owner_proc = 0,
177 const int owner_proc = 0,
223 std::map<int, Range> *received_ents,
286 const int adj_dim,
const int n_parts,
287 Tag *th_vertex_weights =
nullptr,
288 Tag *th_edge_weights =
nullptr,
289 Tag *th_part_weights =
nullptr,
300 std::array<Range, 4> &&, std::vector<const CubitMeshSets *> &&)>;
302 static std::array<Range, 4>
304 std::vector<const CubitMeshSets *> &&vec_ptr) {
305 return proc_ents_skin;
319 moab::Interface &moab,
const char *file_name,
int dim,
321 const char *options =
"PARALLEL=BCAST;PARTITION=");
365 const int nb_coeffs,
Sev sev = Sev::verbose,
366 int root_rank = 0,
bool get_vertices =
true);
385 const int nb_coeffs,
Sev sev = Sev::verbose,
394 CHKERR VecGhostUpdateBegin(
v, ADD_VALUES, SCATTER_REVERSE);
395 CHKERR VecGhostUpdateEnd(
v, ADD_VALUES, SCATTER_REVERSE);
396 CHKERR VecGhostUpdateBegin(
v, INSERT_VALUES, SCATTER_FORWARD);
397 CHKERR VecGhostUpdateEnd(
v, INSERT_VALUES, SCATTER_FORWARD);
#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)
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.
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
static Range getPartEntities(moab::Interface &moab, int part)
~CommInterface()=default
Destructor.
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 * > &&vec_ptr)
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)
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)
static MoFEMErrorCode setTagFromVector(moab::Interface &moab, EntitiesPetscVector &vec, Tag tag)
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 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.
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