Commit 08049157 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#976 Petsc/Vector: Copy() and CompleteCopy() now by default call...

#976 Petsc/Vector: Copy() and CompleteCopy() now by default call UpdateGhosts() after the copy itself. This can be deactivated with an optional argument.
parent e2867bdc
......@@ -321,19 +321,30 @@ namespace HappyHeart
}
void Vector::Copy(const Vector& source, const char* invoking_file, int invoking_line)
void Vector::Copy(const Vector& source, const char* invoking_file, int invoking_line,
update_ghost do_update_ghost)
{
int error_code = VecCopy(source.Internal(),
Internal());
if (error_code)
throw ExceptionNS::Exception(error_code, "VecCopy", invoking_file, invoking_line);
switch(do_update_ghost)
{
case update_ghost::yes:
UpdateGhosts(invoking_file, invoking_line);
break;
case update_ghost::no:
break;
}
}
void Vector::CompleteCopy(const Vector& source, const char* invoking_file, int invoking_line)
void Vector::CompleteCopy(const Vector& source, const char* invoking_file, int invoking_line,
update_ghost do_update_ghost)
{
DuplicateLayout(source, invoking_file, invoking_line);
Copy(source, invoking_file, invoking_line);
Copy(source, invoking_file, invoking_line, do_update_ghost);
}
......
......@@ -63,6 +63,9 @@ namespace HappyHeart
// ============================
//! Enum class to specify if in a copy ghosts are updated or not.
enum class update_ghost { yes, no };
namespace Wrappers
{
......@@ -386,7 +389,8 @@ namespace HappyHeart
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
void SetValue(PetscInt index, PetscScalar value, InsertMode insertOrAppend, const char* invoking_file, int invoking_line);
void SetValue(PetscInt index, PetscScalar value, InsertMode insertOrAppend,
const char* invoking_file, int invoking_line);
/*!
......@@ -399,7 +403,12 @@ namespace HappyHeart
void SetUniformValue(PetscScalar value, const char* invoking_file, int invoking_line);
/*!
* \class doxygen_hide_do_update_ghost_arg
*
* \param[in] do_update_ghost Whether the target gets its ghost automatically updated or not.
* Default is yes.
*/
/*!
* \brief A wrapper over VecCopy, which assumed target already gets the right layout.
......@@ -409,8 +418,10 @@ namespace HappyHeart
* the same between object for which the method is called and \a source.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
* \copydoc doxygen_hide_do_update_ghost_arg
*/
void Copy(const Vector& source, const char* invoking_file, int invoking_line);
void Copy(const Vector& source, const char* invoking_file, int invoking_line,
update_ghost do_update_ghost = update_ghost::yes);
/*!
......@@ -419,8 +430,10 @@ namespace HappyHeart
* \param[in] source Original vector which layout AND content is copied.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
* \copydoc doxygen_hide_do_update_ghost_arg
*/
void CompleteCopy(const Vector& source, const char* invoking_file, int invoking_line);
void CompleteCopy(const Vector& source, const char* invoking_file, int invoking_line,
update_ghost do_update_ghost = update_ghost::yes);
/*!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment