Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patchkernel: add the concept of "adaption mode" #371

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions src/lineunstructured/lineunstructured.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ namespace bitpit {
among the processes
*/
LineUnstructured::LineUnstructured(MPI_Comm communicator)
: LineKernel(communicator, 1, true)
: LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED)
#else
/*!
Creates an uninitialized serial patch.
*/
LineUnstructured::LineUnstructured()
: LineKernel(true)
: LineKernel(ADAPTION_MANUAL)
#endif
{
}
Expand All @@ -74,15 +74,15 @@ LineUnstructured::LineUnstructured()
among the processes
*/
LineUnstructured::LineUnstructured(int dimension, MPI_Comm communicator)
: LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, true)
: LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED)
#else
/*!
Creates a patch.

\param dimension is the dimension of the patch
*/
LineUnstructured::LineUnstructured(int dimension)
: LineKernel(PatchManager::AUTOMATIC_ID, dimension, true)
: LineKernel(PatchManager::AUTOMATIC_ID, dimension, ADAPTION_MANUAL)
#endif
{
}
Expand All @@ -101,7 +101,7 @@ LineUnstructured::LineUnstructured(int dimension)
among the processes
*/
LineUnstructured::LineUnstructured(int id, int dimension, MPI_Comm communicator)
: LineKernel(id, dimension, communicator, 1, true)
: LineKernel(id, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED)
#else
/*!
Creates a patch.
Expand All @@ -110,7 +110,7 @@ LineUnstructured::LineUnstructured(int id, int dimension, MPI_Comm communicator)
\param dimension is the dimension of the patch
*/
LineUnstructured::LineUnstructured(int id, int dimension)
: LineKernel(id, dimension, true)
: LineKernel(id, dimension, ADAPTION_MANUAL)
#endif
{
}
Expand All @@ -127,15 +127,15 @@ LineUnstructured::LineUnstructured(int id, int dimension)
among the processes
*/
LineUnstructured::LineUnstructured(std::istream &stream, MPI_Comm communicator)
: LineKernel(communicator, 1, false)
: LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED)
#else
/*!
Creates a patch restoring the patch saved in the specified stream.

\param stream is the stream to read from
*/
LineUnstructured::LineUnstructured(std::istream &stream)
: LineKernel(false)
: LineKernel(ADAPTION_MANUAL)
#endif
{
// Restore the patch
Expand All @@ -152,20 +152,6 @@ std::unique_ptr<PatchKernel> LineUnstructured::clone() const
return std::unique_ptr<LineUnstructured>(new LineUnstructured(*this));
}

/*!
* Enables or disables expert mode.
*
* When expert mode is enabled, it will be possible to change the
* patch using low level functions (e.g., it will be possible to
* add individual cells, add vertices, delete cells, ...).
*
* \param expert if true, the expert mode will be enabled
*/
void LineUnstructured::setExpert(bool expert)
{
LineKernel::setExpert(expert);
}

/*!
* Get the version associated to the binary dumps.
*
Expand Down
2 changes: 1 addition & 1 deletion src/lineunstructured/lineunstructured.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LineUnstructured : public LineKernel {
std::unique_ptr<PatchKernel> clone() const override;

// Setters
void setExpert(bool expert);
using LineKernel::setExpert;

// Search algorithms
long locatePoint(const std::array<double, 3> &point) const override;
Expand Down
45 changes: 27 additions & 18 deletions src/patchkernel/line_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ namespace bitpit {
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize, bool expert)
: PatchKernel(communicator, haloSize, expert)
LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.

\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(bool expert)
: PatchKernel(expert)
LineKernel::LineKernel(AdaptionMode adaptionMode)
: PatchKernel(adaptionMode)
#endif
{
initialize();
Expand All @@ -71,19 +74,22 @@ LineKernel::LineKernel(bool expert)
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert)
: PatchKernel(dimension, communicator, haloSize, expert)
LineKernel::LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.

\param dimension is the dimension of the patch
\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(int dimension, bool expert)
: PatchKernel(dimension, expert)
LineKernel::LineKernel(int dimension, AdaptionMode adaptionMode)
: PatchKernel(dimension, adaptionMode)
#endif
{
initialize();
Expand All @@ -104,20 +110,23 @@ LineKernel::LineKernel(int dimension, bool expert)
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert)
: PatchKernel(id, dimension, communicator, haloSize, expert)
LineKernel::LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.

\param id is the id that will be assigned to the patch
\param dimension is the dimension of the patch
\param expert if true, the expert mode will be enabled
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(int id, int dimension, bool expert)
: PatchKernel(id, dimension, expert)
LineKernel::LineKernel(int id, int dimension, AdaptionMode adaptionMode)
: PatchKernel(id, dimension, adaptionMode)
#endif
{
}
Expand Down
12 changes: 6 additions & 6 deletions src/patchkernel/line_kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class LineKernel : public PatchKernel {

protected:
#if BITPIT_ENABLE_MPI==1
LineKernel(MPI_Comm communicator, std::size_t haloSize, bool expert);
LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert);
LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert);
LineKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode);
LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode);
LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode);
#else
LineKernel(bool expert);
LineKernel(int dimension, bool expert);
LineKernel(int id, int dimension, bool expert);
LineKernel(AdaptionMode adaptionMode);
LineKernel(int dimension, AdaptionMode adaptionMode);
LineKernel(int id, int dimension, AdaptionMode adaptionMode);
#endif

};
Expand Down
Loading