v0.10.0
Files | Functions
Vectors (Vec)

Creating and scattering vectors on the mesh for given problem. More...

Collaboration diagram for Vectors (Vec):

Files

file  VecManager.hpp
 Interface managing vectorsManaging problems, build and partitioning.
 

Functions

MoFEMErrorCode MoFEM::VecManager::vecCreateSeq (const std::string &name, RowColData rc, Vec *V) const
 create local vector for problem More...
 
MoFEMErrorCode MoFEM::VecManager::vecCreateGhost (const std::string &name, RowColData rc, Vec *V) const
 create ghost vector for problem (collective)collective - need to be run on all processors in communicator More...
 
MoFEMErrorCode MoFEM::VecManager::vecScatterCreate (Vec xin, const std::string &x_problem, const std::string &x_field_name, RowColData x_rc, Vec yin, const std::string &y_problem, const std::string &y_field_name, RowColData y_rc, VecScatter *newctx) const
 create scatter for vectors form one to another problem (collective)User specify what name of field on one problem is scattered to another. More...
 
MoFEMErrorCode MoFEM::VecManager::vecScatterCreate (Vec xin, const std::string &x_problem, RowColData x_rc, Vec yin, const std::string &y_problem, RowColData y_rc, VecScatter *newctx) const
 create scatter for vectors form one to another problem (collective) More...
 
MoFEMErrorCode MoFEM::VecManager::setLocalGhostVector (const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to meshdatabase More...
 
MoFEMErrorCode MoFEM::VecManager::setLocalGhostVector (const std::string &name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to meshdatabase More...
 
MoFEMErrorCode MoFEM::VecManager::setGlobalGhostVector (const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator More...
 
MoFEMErrorCode MoFEM::VecManager::setGlobalGhostVector (const std::string &name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator More...
 
MoFEMErrorCode MoFEM::VecManager::setOtherLocalGhostVector (const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 Copy vector to field which is not part of the problem. More...
 
MoFEMErrorCode MoFEM::VecManager::setOtherLocalGhostVector (const std::string &name, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 Copy vector to field which is not part of the problem. More...
 
MoFEMErrorCode MoFEM::VecManager::setOtherGlobalGhostVector (const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator. More...
 
MoFEMErrorCode MoFEM::VecManager::setOtherGlobalGhostVector (const std::string &name, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator. More...
 

Create vectors

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecCreateSeq (const std::string &name, RowColData rc, Vec *V) const
 create local vector for problem More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecCreateGhost (const std::string &name, RowColData rc, Vec *V) const
 create ghost vector for problem (collective)collective - need to be run on all processors in communicator More...
 

Create IS

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::ISCreateProblemFieldAndRank (const std::string &problem, RowColData rc, const std::string &field, int min_coeff_idx, int max_coeff_idx, IS *is, int verb=-1) const
 create IS for given problem, field and rank range (collective) More...
 

Scatter vectors

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecScatterCreate (Vec xin, const std::string &x_problem, const std::string &x_field_name, RowColData x_rc, Vec yin, const std::string &y_problem, const std::string &y_field_name, RowColData y_rc, VecScatter *newctx, int verb=-1) const
 create scatter for vectors form one to another problem (collective)User specify what name of field on one problem is scattered to another. More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecScatterCreate (Vec xin, const std::string &x_problem, RowColData x_rc, Vec yin, const std::string &y_problem, RowColData y_rc, VecScatter *newctx, int verb=-1) const
 create scatter for vectors form one to another problem (collective) More...
 

Set vector and mesh values

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_local_ghost_vector (const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to meshdatabase More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_local_ghost_vector (const std::string &name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to meshdatabase More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_global_ghost_vector (const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_global_ghost_vector (const std::string &name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
 set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_local_ghost_vector (const Problem *problem_ptr, const std::string &fiel_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
 Copy vector to field which is not part of the problem. More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_local_ghost_vector (const std::string &name, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
 Copy vector to field which is not part of the problem. More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_global_ghost_vector (const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
 Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator. More...
 
DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_global_ghost_vector (const std::string &name, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
 Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator. More...
 

Detailed Description

Creating and scattering vectors on the mesh for given problem.

Function Documentation

◆ ISCreateProblemFieldAndRank()

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::ISCreateProblemFieldAndRank ( const std::string &  problem,
RowColData  rc,
const std::string &  field,
int  min_coeff_idx,
int  max_coeff_idx,
IS *  is,
int  verb = -1 
) const

create IS for given problem, field and rank range (collective)

Deprecated:
Use ISManager
Parameters
problemname
rcROW or COL
fieldname
min_coeff_idx
max_coeff_idx
Return values
isout value

Definition at line 143 of file DeprecatedCoreInterface.cpp.

145  {
146  return getInterface<ISManager>()->isCreateProblemFieldAndRank(
147  problem, rc, field, min_coeff_idx, max_coeff_idx, is);
148 }

◆ set_global_ghost_vector() [1/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_global_ghost_vector ( const Problem problem_ptr,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator

Deprecated:
use VecManager
Parameters
pointerto porblem struture
RowColDatafor row or column (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 196 of file DeprecatedCoreInterface.cpp.

198  {
199  return getInterface<VecManager>()->setGlobalGhostVector(problem_ptr, rc, V,
200  mode, scatter_mode);
201 }

◆ set_global_ghost_vector() [2/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_global_ghost_vector ( const std::string &  name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator

Deprecated:
use VecManager
Parameters
nameof the problem
RowColDatafor row or column (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 202 of file DeprecatedCoreInterface.cpp.

204  {
205  return getInterface<VecManager>()->setGlobalGhostVector(name, rc, V, mode,
206  scatter_mode);
207 }

◆ set_local_ghost_vector() [1/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_local_ghost_vector ( const Problem problem_ptr,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to meshdatabase

Deprecated:
use VecManager
Parameters
pointerto problem struture
RowColDatafor row or column:e (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 184 of file DeprecatedCoreInterface.cpp.

186  {
187  return getInterface<VecManager>()->setLocalGhostVector(problem_ptr, rc, V,
188  mode, scatter_mode);
189 }

◆ set_local_ghost_vector() [2/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_local_ghost_vector ( const std::string &  name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to meshdatabase

Deprecated:
use VecManager
Parameters
nameof the problem
RowColDatafor row or column:e (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 190 of file DeprecatedCoreInterface.cpp.

192  {
193  return getInterface<VecManager>()->setLocalGhostVector(name, rc, V, mode,
194  scatter_mode);
195 }

◆ set_other_global_ghost_vector() [1/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_global_ghost_vector ( const Problem problem_ptr,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode,
int  verb = -1 
)

Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator.

Deprecated:
use VecManager
Parameters
problem_ptrpointer to problem
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 222 of file DeprecatedCoreInterface.cpp.

225  {
226  return getInterface<VecManager>()->setOtherGlobalGhostVector(
227  problem_ptr, field_name, cpy_field_name, rc, V, mode, scatter_mode);
228 }

◆ set_other_global_ghost_vector() [2/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_global_ghost_vector ( const std::string &  name,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode,
int  verb = -1 
)

Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator.

Deprecated:
use VecManager
Parameters
nameproblem name
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 229 of file DeprecatedCoreInterface.cpp.

232  {
233  return getInterface<VecManager>()->setOtherGlobalGhostVector(
234  name, field_name, cpy_field_name, rc, V, mode, scatter_mode);
235 }

◆ set_other_local_ghost_vector() [1/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_local_ghost_vector ( const Problem problem_ptr,
const std::string &  fiel_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode,
int  verb = -1 
)

Copy vector to field which is not part of the problem.

Deprecated:
use VecManager
Parameters
pointerto poroblem multi_index
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 208 of file DeprecatedCoreInterface.cpp.

211  {
212  return getInterface<VecManager>()->setOtherLocalGhostVector(
213  problem_ptr, field_name, cpy_field_name, rc, V, mode, scatter_mode);
214 }

◆ set_other_local_ghost_vector() [2/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_other_local_ghost_vector ( const std::string &  name,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode,
int  verb = -1 
)

Copy vector to field which is not part of the problem.

Deprecated:
use VecManager
Parameters
nameproblem name
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 215 of file DeprecatedCoreInterface.cpp.

218  {
219  return getInterface<VecManager>()->setOtherLocalGhostVector(
220  name, field_name, cpy_field_name, rc, V, mode, scatter_mode);
221 }

◆ setGlobalGhostVector() [1/2]

MoFEMErrorCode MoFEM::VecManager::setGlobalGhostVector ( const Problem problem_ptr,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator

Parameters
pointerto porblem struture
RowColDatafor row or column (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 286 of file VecManager.cpp.

288  {
291  DofsByGlobalIdx;
292  DofsByGlobalIdx *dofs;
293  DofIdx nb_dofs;
294  switch (rc) {
295  case ROW:
296  nb_dofs = problem_ptr->getNbDofsRow();
297  dofs = const_cast<DofsByGlobalIdx *>(
298  &problem_ptr->numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>());
299  break;
300  case COL:
301  nb_dofs = problem_ptr->getNbDofsCol();
302  dofs = const_cast<DofsByGlobalIdx *>(
303  &problem_ptr->numeredColDofsPtr->get<PetscGlobalIdx_mi_tag>());
304  break;
305  default:
306  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
307  }
308  DofsByGlobalIdx::iterator miit = dofs->lower_bound(0);
309  DofsByGlobalIdx::iterator hi_miit = dofs->upper_bound(nb_dofs);
310  switch (scatter_mode) {
311  case SCATTER_REVERSE: {
312  VecScatter ctx;
313  Vec V_glob;
314  CHKERR VecScatterCreateToAll(V, &ctx, &V_glob);
315  CHKERR VecScatterBegin(ctx, V, V_glob, INSERT_VALUES, SCATTER_FORWARD);
316  CHKERR VecScatterEnd(ctx, V, V_glob, INSERT_VALUES, SCATTER_FORWARD);
317  int size;
318  CHKERR VecGetSize(V_glob, &size);
319  if (size != nb_dofs) {
320  SETERRQ(
321  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
322  "data inconsistency: nb. of dofs and declared nb. dofs in database");
323  }
324  PetscScalar *array;
325  CHKERR VecGetArray(V_glob, &array);
326  switch (mode) {
327  case INSERT_VALUES:
328  for (; miit != hi_miit; miit++)
329  (*miit)->getFieldData() = array[(*miit)->getPetscGlobalDofIdx()];
330  break;
331  case ADD_VALUES:
332  for (; miit != hi_miit; miit++)
333  (*miit)->getFieldData() += array[(*miit)->getPetscGlobalDofIdx()];
334  break;
335  default:
336  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
337  }
338  CHKERR VecRestoreArray(V_glob, &array);
339  CHKERR VecScatterDestroy(&ctx);
340  CHKERR VecDestroy(&V_glob);
341  break;
342  }
343  default:
344  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
345  }
347 }
const FTensor::Tensor2< T, Dim, Dim > Vec
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define CHKERR
Inline error check.
Definition: definitions.h:604
int DofIdx
Index of DOF.
Definition: Types.hpp:29
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ setGlobalGhostVector() [2/2]

MoFEMErrorCode MoFEM::VecManager::setGlobalGhostVector ( const std::string &  name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to mesh database (collective)collective - need tu be run on all processors in communicator

Parameters
nameof the problem
RowColDatafor row or column (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 350 of file VecManager.cpp.

352  {
353  const MoFEM::Interface &m_field = cOre;
354  const Problem *problem_ptr;
356  CHKERR m_field.get_problem(name, &problem_ptr);
357  CHKERR setGlobalGhostVector(problem_ptr, rc, V, mode, scatter_mode);
359 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
MoFEMErrorCode setGlobalGhostVector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to mesh database (collective)collective - need tu be run on all processors ...
Definition: VecManager.cpp:286
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ setLocalGhostVector() [1/2]

MoFEMErrorCode MoFEM::VecManager::setLocalGhostVector ( const Problem problem_ptr,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to meshdatabase

Parameters
pointerto problem struture
RowColDatafor row or column:e (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 184 of file VecManager.cpp.

187  {
190  DofIdx nb_local_dofs, nb_ghost_dofs;
191  switch (rc) {
192  case ROW:
193  nb_local_dofs = problem_ptr->getNbLocalDofsRow();
194  nb_ghost_dofs = problem_ptr->getNbGhostDofsRow();
195  dofs = const_cast<NumeredDofEntityByLocalIdx *>(
196  &problem_ptr->numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>());
197  break;
198  case COL:
199  nb_local_dofs = problem_ptr->getNbLocalDofsCol();
200  nb_ghost_dofs = problem_ptr->getNbGhostDofsCol();
201  dofs = const_cast<NumeredDofEntityByLocalIdx *>(
202  &problem_ptr->numeredColDofsPtr->get<PetscLocalIdx_mi_tag>());
203  break;
204  default:
205  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
206  }
207  Vec Vlocal;
208  CHKERR VecGhostGetLocalForm(V, &Vlocal);
209  int size;
210  CHKERR VecGetLocalSize(V, &size);
211  if (size != nb_local_dofs) {
212  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
213  "data inconsistency: check ghost vector, problem with nb. of "
214  "local nodes %d != %d",
215  size, nb_local_dofs);
216  }
217  CHKERR VecGetLocalSize(Vlocal, &size);
218  if (size != nb_local_dofs + nb_ghost_dofs) {
219  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
220  "data inconsistency: check ghost vector, problem with nb. of "
221  "ghost nodes %d != ",
222  size, nb_local_dofs + nb_ghost_dofs);
223  }
224  NumeredDofEntityByLocalIdx::iterator miit = dofs->lower_bound(0);
225  NumeredDofEntityByLocalIdx::iterator hi_miit =
226  dofs->upper_bound(nb_local_dofs + nb_ghost_dofs);
227  DofIdx ii = 0;
228  switch (scatter_mode) {
229  case SCATTER_FORWARD: {
230  PetscScalar *array;
231  CHKERR VecGetArray(Vlocal, &array);
232  switch (mode) {
233  case INSERT_VALUES:
234  for (; miit != hi_miit; ++miit, ++ii)
235  array[ii] = (*miit)->getFieldData();
236  break;
237  case ADD_VALUES:
238  for (; miit != hi_miit; ++miit, ++ii)
239  array[ii] += (*miit)->getFieldData();
240  break;
241  default:
242  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
243  }
244  CHKERR VecRestoreArray(Vlocal, &array);
245  }; break;
246  case SCATTER_REVERSE: {
247  const PetscScalar *array;
248  CHKERR VecGetArrayRead(Vlocal, &array);
249  switch (mode) {
250  case INSERT_VALUES:
251  for (; miit != hi_miit; ++miit, ++ii) {
252  // std::cerr << *miit << std::endl;
253  // std::cerr << array[ii] << std::endl;
254  (*miit)->getFieldData() = array[ii];
255  }
256  break;
257  case ADD_VALUES:
258  for (; miit != hi_miit; ++miit, ++ii)
259  (*miit)->getFieldData() += array[ii];
260  break;
261  default:
262  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
263  }
264  CHKERR VecRestoreArrayRead(Vlocal, &array);
265  }; break;
266  default:
267  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
268  }
269  CHKERR VecGhostRestoreLocalForm(V, &Vlocal);
271 }
const FTensor::Tensor2< T, Dim, Dim > Vec
NumeredDofEntity_multiIndex::index< PetscLocalIdx_mi_tag >::type NumeredDofEntityByLocalIdx
Numbered DoF multi-index by local index.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define CHKERR
Inline error check.
Definition: definitions.h:604
int DofIdx
Index of DOF.
Definition: Types.hpp:29
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ setLocalGhostVector() [2/2]

MoFEMErrorCode MoFEM::VecManager::setLocalGhostVector ( const std::string &  name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

set values of vector from/to meshdatabase

Parameters
nameof the problem
RowColDatafor row or column:e (i.e. Row,Col)
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 273 of file VecManager.cpp.

276  {
277  const MoFEM::Interface &m_field = cOre;
278  const Problem *problem_ptr;
280  CHKERR m_field.get_problem(name, &problem_ptr);
281  CHKERR setLocalGhostVector(problem_ptr, rc, V, mode, scatter_mode);
283 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
MoFEMErrorCode setLocalGhostVector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to meshdatabase
Definition: VecManager.cpp:184
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ setOtherGlobalGhostVector() [1/2]

MoFEMErrorCode MoFEM::VecManager::setOtherGlobalGhostVector ( const Problem problem_ptr,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator.

Parameters
problem_ptrpointer to problem
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 518 of file VecManager.cpp.

521  {
522  const MoFEM::Interface &m_field = cOre;
523  auto fields_ptr = m_field.get_fields();
524  auto dofs_ptr = m_field.get_dofs();
525  auto *field_ents = m_field.get_field_ents();
527  NumeredDofEntityByUId *dofs;
528  DofIdx nb_dofs;
529  switch (rc) {
530  case ROW:
531  nb_dofs = problem_ptr->getNbDofsRow();
532  dofs = const_cast<NumeredDofEntityByUId *>(
533  &problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>());
534  break;
535  case COL:
536  nb_dofs = problem_ptr->getNbDofsCol();
537  dofs = const_cast<NumeredDofEntityByUId *>(
538  &problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>());
539  break;
540  default:
541  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "not implemented");
542  }
543  auto cpy_fit = fields_ptr->get<FieldName_mi_tag>().find(cpy_field_name);
544  if (cpy_fit == fields_ptr->get<FieldName_mi_tag>().end()) {
545  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND,
546  "cpy field < %s > not found, (top tip: check spelling)",
547  cpy_field_name.c_str());
548  }
549  const auto cpy_bit_number = (*cpy_fit)->getBitNumber();
550 
551  auto miit = dofs->lower_bound(
553  if (miit == dofs->end()) {
554  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND,
555  "problem field < %s > not found, (top tip: check spelling)",
556  field_name.c_str());
557  }
558  auto hi_miit = dofs->upper_bound(
560  if ((*miit)->getSpace() != (*cpy_fit)->getSpace()) {
561  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
562  "fields have to have same space");
563  }
564  if ((*miit)->getNbOfCoeffs() != (*cpy_fit)->getNbOfCoeffs()) {
565  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
566  "fields have to have same rank");
567  }
568  switch (scatter_mode) {
569  case SCATTER_REVERSE: {
570  Vec V_glob;
571  VecScatter ctx;
572  CHKERR VecScatterCreateToAll(V, &ctx, &V_glob);
573  CHKERR VecScatterBegin(ctx, V, V_glob, INSERT_VALUES, SCATTER_FORWARD);
574  CHKERR VecScatterEnd(ctx, V, V_glob, INSERT_VALUES, SCATTER_FORWARD);
575  int size;
576  CHKERR VecGetSize(V_glob, &size);
577  if (size != nb_dofs)
578  SETERRQ(
579  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
580  "data inconsistency: nb. of dofs and declared nb. dofs in database");
581  PetscScalar *array;
582  CHKERR VecGetArray(V_glob, &array);
583 
584  if (mode == INSERT_VALUES)
585  CHKERR SetOtherGlobalGhostVector<INSERT_VALUES>()(
586  dofs_ptr, array, miit, hi_miit, cpy_bit_number);
587  else if (mode == ADD_VALUES)
588  CHKERR SetOtherGlobalGhostVector<ADD_VALUES>()(dofs_ptr, array, miit,
589  hi_miit, cpy_bit_number);
590  else
591  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
592  "Operation mode not implemented");
593 
594  CHKERR VecRestoreArray(V_glob, &array);
595  CHKERR VecDestroy(&V_glob);
596  CHKERR VecScatterDestroy(&ctx);
597  } break;
598  case SCATTER_FORWARD: {
599  for (; miit != hi_miit; miit++) {
600  const auto uid = DofEntity::getUniqueIdCalculate(
601  (*miit)->getEntDofIdx(), FieldEntity::getLocalUniqueIdCalculate(
602  cpy_bit_number, (*miit)->getEnt()));
603  auto diiiit = dofs_ptr->get<Unique_mi_tag>().find(uid);
604  if (diiiit ==
605  dofs_ptr->get<Unique_mi_tag>().end()) {
606  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
607  "No data to fill the vector (top tip: you want scatter forward "
608  "or scatter reverse?)");
609  }
610  CHKERR VecSetValue(V, (*miit)->getPetscGlobalDofIdx(),
611  (*diiiit)->getFieldData(), mode);
612  }
613  CHKERR VecAssemblyBegin(V);
614  CHKERR VecAssemblyEnd(V);
615  } break;
616  default:
617  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
618  }
620 }
Deprecated interface functions.
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
UId getLocalUniqueIdCalculate()
Get the Local Unique Id Calculate object.
const FTensor::Tensor2< T, Dim, Dim > Vec
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
virtual const FieldEntity_multiIndex * get_field_ents() const =0
Get the field ents object.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
NumeredDofEntity_multiIndex::index< Unique_mi_tag >::type NumeredDofEntityByUId
Numbered DoF multi-index by UId.
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
#define CHKERR
Inline error check.
Definition: definitions.h:604
static UId getUniqueIdCalculate(const DofIdx dof, UId ent_uid)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
int DofIdx
Index of DOF.
Definition: Types.hpp:29
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
static UId getHiBitNumberUId(const FieldBitNumber bit_number)

◆ setOtherGlobalGhostVector() [2/2]

MoFEMErrorCode MoFEM::VecManager::setOtherGlobalGhostVector ( const std::string &  name,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

Copy vector to field which is not part of the problem (collective)collective - need tu be run on all processors in communicator.

Deprecated:
VecManager
Parameters
nameproblem name
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 622 of file VecManager.cpp.

625  {
626  const MoFEM::Interface &m_field = cOre;
627  const Problem *problem_ptr;
629  CHKERR m_field.get_problem(name, &problem_ptr);
630  CHKERR setOtherGlobalGhostVector(problem_ptr, field_name, cpy_field_name, rc,
631  V, mode, scatter_mode);
633 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode setOtherGlobalGhostVector(const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
Copy vector to field which is not part of the problem (collective)collective - need tu be run on all ...
Definition: VecManager.cpp:518

◆ setOtherLocalGhostVector() [1/2]

MoFEMErrorCode MoFEM::VecManager::setOtherLocalGhostVector ( const Problem problem_ptr,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

Copy vector to field which is not part of the problem.

Parameters
pointerto problem multi_index
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 389 of file VecManager.cpp.

392  {
393  const MoFEM::Interface &m_field = cOre;
394  auto fields_ptr = m_field.get_fields();
395  auto dofs_ptr = m_field.get_dofs();
398  DofsByUId *dofs;
399 
400  switch (rc) {
401  case ROW:
402  dofs = const_cast<DofsByUId *>(
403  &problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>());
404  break;
405  case COL:
406  dofs = const_cast<DofsByUId *>(
407  &problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>());
408  break;
409  default:
410  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
411  }
412 
413  auto cpy_fit = fields_ptr->get<FieldName_mi_tag>().find(cpy_field_name);
414  if (cpy_fit == fields_ptr->get<FieldName_mi_tag>().end())
415  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND,
416  "cpy field < %s > not found, (top tip: check spelling)",
417  cpy_field_name.c_str());
418  const auto cpy_bit_number = (*cpy_fit)->getBitNumber();
419 
420  auto miit = dofs->lower_bound(
422  if (miit == dofs->end()) {
423  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND,
424  "cpy field < %s > not found, (top tip: check spelling)",
425  field_name.c_str());
426  }
427  auto hi_miit = dofs->upper_bound(
429 
430  if ((*miit)->getSpace() != (*cpy_fit)->getSpace()) {
431  SETERRQ4(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
432  "fields have to have same space (%s) %s != (%s) %s",
433  (*miit)->getName().c_str(), FieldSpaceNames[(*miit)->getSpace()],
434  cpy_field_name.c_str(), FieldSpaceNames[(*cpy_fit)->getSpace()]);
435  }
436  if ((*miit)->getNbOfCoeffs() != (*cpy_fit)->getNbOfCoeffs()) {
437  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
438  "fields have to have same rank");
439  }
440 
441  switch (scatter_mode) {
442  case SCATTER_REVERSE: {
443 
444  PetscScalar *array;
445  CHKERR VecGetArray(V, &array);
446  if (mode == INSERT_VALUES)
447  CHKERR SetOtherLocalGhostVector<INSERT_VALUES>()(dofs_ptr, array, miit,
448  hi_miit, cpy_bit_number);
449  else if (mode == ADD_VALUES)
450  CHKERR SetOtherLocalGhostVector<ADD_VALUES>()(dofs_ptr, array, miit,
451  hi_miit, cpy_bit_number);
452  else
453  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
454  "Operation mode not implemented");
455  CHKERR VecRestoreArray(V, &array);
456  } break;
457  case SCATTER_FORWARD: {
458  for (; miit != hi_miit; miit++) {
459  if (!miit->get()->getHasLocalIndex())
460  continue;
461  const auto uid = DofEntity::getUniqueIdCalculate(
462  (*miit)->getEntDofIdx(), FieldEntity::getLocalUniqueIdCalculate(
463  cpy_bit_number, (*miit)->getEnt()));
464  auto diiiit = dofs_ptr->get<Unique_mi_tag>().find(uid);
465  if (diiiit == dofs_ptr->get<Unique_mi_tag>().end()) {
466  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
467  "no data to fill the vector (top tip: you want scatter forward "
468  "or scatter reverse?)");
469  }
470  CHKERR VecSetValue(V, (*miit)->getPetscGlobalDofIdx(),
471  (*diiiit)->getFieldData(), mode);
472  }
473  CHKERR VecAssemblyBegin(V);
474  CHKERR VecAssemblyEnd(V);
475  } break;
476  default:
477  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "not implemented");
478  }
480 }
Deprecated interface functions.
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
UId getLocalUniqueIdCalculate()
Get the Local Unique Id Calculate object.
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
static const char *const FieldSpaceNames[]
Definition: definitions.h:184
#define CHKERR
Inline error check.
Definition: definitions.h:604
static UId getUniqueIdCalculate(const DofIdx dof, UId ent_uid)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
static UId getHiBitNumberUId(const FieldBitNumber bit_number)

◆ setOtherLocalGhostVector() [2/2]

MoFEMErrorCode MoFEM::VecManager::setOtherLocalGhostVector ( const std::string &  name,
const std::string &  field_name,
const std::string &  cpy_field_name,
RowColData  rc,
Vec  V,
InsertMode  mode,
ScatterMode  scatter_mode 
) const

Copy vector to field which is not part of the problem.

Parameters
nameproblem name
field_namefield name used for indexing petsc vectors used in the problem
cpy_fieldfield name where data from vector are stored
RowColDatafor row or column
Vvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities form V vector.

Definition at line 482 of file VecManager.cpp.

485  {
486  const MoFEM::Interface &m_field = cOre;
487  const Problem *problem_ptr;
489  CHKERR m_field.get_problem(name, &problem_ptr);
490  CHKERR setOtherLocalGhostVector(problem_ptr, field_name, cpy_field_name, rc,
491  V, mode, scatter_mode);
493 }
MoFEMErrorCode setOtherLocalGhostVector(const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
Copy vector to field which is not part of the problem.
Definition: VecManager.cpp:389
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ vecCreateGhost()

MoFEMErrorCode MoFEM::VecManager::vecCreateGhost ( const std::string &  name,
RowColData  rc,
Vec *  V 
) const

create ghost vector for problem (collective)collective - need to be run on all processors in communicator

Parameters
nameproblem name
RowColDataspecify what data is taken from Row, Col or Data
Vecthe vector where data is stored

Definition at line 59 of file VecManager.cpp.

60  {
61  const MoFEM::Interface &m_field = cOre;
62  const Problem *problem_ptr;
64  CHKERR m_field.get_problem(name, &problem_ptr);
65  DofIdx nb_dofs, nb_local_dofs, nb_ghost_dofs;
67  switch (rc) {
68  case ROW:
69  nb_dofs = problem_ptr->getNbDofsRow();
70  nb_local_dofs = problem_ptr->getNbLocalDofsRow();
71  nb_ghost_dofs = problem_ptr->getNbGhostDofsRow();
72  dofs = const_cast<NumeredDofEntityByLocalIdx *>(
73  &problem_ptr->numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>());
74  break;
75  case COL:
76  nb_dofs = problem_ptr->getNbDofsCol();
77  nb_local_dofs = problem_ptr->getNbLocalDofsCol();
78  nb_ghost_dofs = problem_ptr->getNbGhostDofsCol();
79  dofs = const_cast<NumeredDofEntityByLocalIdx *>(
80  &problem_ptr->numeredColDofsPtr->get<PetscLocalIdx_mi_tag>());
81  break;
82  default:
83  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
84  }
85  // get ghost dofs
86  auto miit = dofs->lower_bound(nb_local_dofs);
87  auto hi_miit = dofs->upper_bound(nb_local_dofs + nb_ghost_dofs);
88  int count = std::distance(miit, hi_miit);
89  if (count != nb_ghost_dofs) {
90  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
91  }
92  std::vector<DofIdx> ghost_idx(count);
93  for (auto vit = ghost_idx.begin(); miit != hi_miit; ++miit, ++vit) {
94  *vit = (*miit)->petscGloablDofIdx;
95  }
96  CHKERR ::VecCreateGhost(PETSC_COMM_WORLD, nb_local_dofs, nb_dofs,
97  nb_ghost_dofs, &ghost_idx[0], V);
99 }
Deprecated interface functions.
NumeredDofEntity_multiIndex::index< PetscLocalIdx_mi_tag >::type NumeredDofEntityByLocalIdx
Numbered DoF multi-index by local index.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
int DofIdx
Index of DOF.
Definition: Types.hpp:29
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ VecCreateGhost()

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecCreateGhost ( const std::string &  name,
RowColData  rc,
Vec *  V 
) const

create ghost vector for problem (collective)collective - need to be run on all processors in communicator

Deprecated:
use VecManager
Parameters
nameproblem name
RowColDataspecify what data is taken from Row, Col or Data
Vecthe vector where data is stored

Definition at line 132 of file DeprecatedCoreInterface.cpp.

134  {
135  return getInterface<VecManager>()->vecCreateGhost(name, rc, V);
136 }

◆ vecCreateSeq()

MoFEMErrorCode MoFEM::VecManager::vecCreateSeq ( const std::string &  name,
RowColData  rc,
Vec *  V 
) const

create local vector for problem

Parameters
nameproblem name
RowColDataspecify what data is taken from Row, Col or Data
Vecthe vector where data is stored

Definition at line 36 of file VecManager.cpp.

37  {
38  const MoFEM::Interface &m_field = cOre;
39  const Problem *problem_ptr;
41  CHKERR m_field.get_problem(name, &problem_ptr);
42  DofIdx nb_local_dofs, nb_ghost_dofs;
43  switch (rc) {
44  case ROW:
45  nb_local_dofs = problem_ptr->getNbLocalDofsRow();
46  nb_ghost_dofs = problem_ptr->getNbGhostDofsRow();
47  break;
48  case COL:
49  nb_local_dofs = problem_ptr->getNbLocalDofsCol();
50  nb_ghost_dofs = problem_ptr->getNbGhostDofsCol();
51  break;
52  default:
53  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
54  }
55  CHKERR ::VecCreateSeq(PETSC_COMM_SELF, nb_local_dofs + nb_ghost_dofs, V);
57 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual const Problem * get_problem(const std::string &problem_name) const =0
Get the problem object.
int DofIdx
Index of DOF.
Definition: Types.hpp:29
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ VecCreateSeq()

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecCreateSeq ( const std::string &  name,
RowColData  rc,
Vec *  V 
) const

create local vector for problem

Deprecated:
use VecManager
Parameters
nameproblem name
RowColDataspecify what data is taken from Row, Col or Data
Vecthe vector where data is stored

Definition at line 127 of file DeprecatedCoreInterface.cpp.

129  {
130  return getInterface<VecManager>()->vecCreateSeq(name, rc, V);
131 }

◆ vecScatterCreate() [1/2]

MoFEMErrorCode MoFEM::VecManager::vecScatterCreate ( Vec  xin,
const std::string &  x_problem,
const std::string &  x_field_name,
RowColData  x_rc,
Vec  yin,
const std::string &  y_problem,
const std::string &  y_field_name,
RowColData  y_rc,
VecScatter *  newctx 
) const

create scatter for vectors form one to another problem (collective)User specify what name of field on one problem is scattered to another.

Parameters
xinvector
x_probleproblem name
x_fieldname
yinvector
y_problemproblem name
y_field_name
Return values
newctxscatter

Definition at line 112 of file VecManager.cpp.

116  {
117  const MoFEM::Interface &m_field = cOre;
119  std::vector<int> idx(0), idy(0);
120  CHKERR m_field.getInterface<ISManager>()
121  ->isCreateFromProblemFieldToOtherProblemField(
122  x_problem, x_field_name, x_rc, y_problem, y_field_name, y_rc, idx,
123  idy);
124  IS ix, iy;
125  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx.size(), &idx[0],
126  PETSC_USE_POINTER, &ix);
127  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idy.size(), &idy[0],
128  PETSC_USE_POINTER, &iy);
129  CHKERR ::VecScatterCreate(xin, ix, yin, iy, newctx);
130  CHKERR ISDestroy(&ix);
131  CHKERR ISDestroy(&iy);
133 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ vecScatterCreate() [2/2]

MoFEMErrorCode MoFEM::VecManager::vecScatterCreate ( Vec  xin,
const std::string &  x_problem,
RowColData  x_rc,
Vec  yin,
const std::string &  y_problem,
RowColData  y_rc,
VecScatter *  newctx 
) const

create scatter for vectors form one to another problem (collective)

Parameters
xinvector
x_probleproblem name
yinvector
y_problemproblem name
Return values
newctxscatter

Definition at line 135 of file VecManager.cpp.

137  {
138  const MoFEM::Interface &m_field = cOre;
140  std::vector<int> idx(0), idy(0);
141  CHKERR m_field.getInterface<ISManager>()->isCreateFromProblemToOtherProblem(
142  x_problem, x_rc, y_problem, y_rc, idx, idy);
143  IS ix, iy;
144  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx.size(), &idx[0],
145  PETSC_USE_POINTER, &ix);
146  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idy.size(), &idy[0],
147  PETSC_USE_POINTER, &iy);
148  if (dEbug) {
149  ISView(ix, PETSC_VIEWER_STDOUT_WORLD);
150  ISView(iy, PETSC_VIEWER_STDOUT_WORLD);
151  }
152  CHKERR ::VecScatterCreate(xin, ix, yin, iy, newctx);
153  CHKERR ISDestroy(&ix);
154  CHKERR ISDestroy(&iy);
156 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
const MoFEM::Interface & cOre
Definition: VecManager.hpp:41
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ VecScatterCreate() [1/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecScatterCreate ( Vec  xin,
const std::string &  x_problem,
const std::string &  x_field_name,
RowColData  x_rc,
Vec  yin,
const std::string &  y_problem,
const std::string &  y_field_name,
RowColData  y_rc,
VecScatter *  newctx,
int  verb = -1 
) const

create scatter for vectors form one to another problem (collective)User specify what name of field on one problem is scattered to another.

Deprecated:
use VecManager
Parameters
xinvector
x_probleproblem name
x_fieldname
yinvector
y_problemproblem name
y_field_name
Return values
newctxscatter

Definition at line 168 of file DeprecatedCoreInterface.cpp.

172  {
173  return getInterface<VecManager>()->vecScatterCreate(
174  xin, x_problem, x_field_name, x_rc, yin, y_problem, y_field_name, y_rc,
175  newctx);
176 }

◆ VecScatterCreate() [2/2]

MoFEMErrorCode MoFEM::DeprecatedCoreInterface::VecScatterCreate ( Vec  xin,
const std::string &  x_problem,
RowColData  x_rc,
Vec  yin,
const std::string &  y_problem,
RowColData  y_rc,
VecScatter *  newctx,
int  verb = -1 
) const

create scatter for vectors form one to another problem (collective)

Deprecated:
use VecManager
Parameters
xinvector
x_probleproblem name
yinvector
y_problemproblem name
Return values
newctxscatter

Definition at line 177 of file DeprecatedCoreInterface.cpp.

180  {
181  return getInterface<VecManager>()->vecScatterCreate(xin, x_problem, x_rc, yin,
182  y_problem, y_rc, newctx);
183 }