-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11297 from KratosMultiphysics/optapp/explicit_ver…
…tex_morphing_new [OptApp] Adding explicit vertex morphing
- Loading branch information
Showing
11 changed files
with
940 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
applications/OptimizationApplication/custom_python/add_custom_filters_to_python.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// license: OptimizationApplication/license.txt | ||
// | ||
// Main author: Suneth Warnakulasuriya | ||
// | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
|
||
// Application includes | ||
#include "custom_utilities/filtering/explicit_vertex_morphing_filter.h" | ||
|
||
// Include base h | ||
#include "add_custom_filters_to_python.h" | ||
|
||
namespace Kratos { | ||
namespace Python { | ||
|
||
namespace Detail | ||
{ | ||
|
||
template <class TContainerType> | ||
void AddExplicitVertexMorphingFilter( | ||
pybind11::module& m, | ||
const std::string& rName) | ||
{ | ||
namespace py = pybind11; | ||
|
||
py::class_<ExplicitVertexMorphingFilter<TContainerType>, typename ExplicitVertexMorphingFilter<TContainerType>::Pointer>(m, rName.c_str()) | ||
.def(py::init<const ModelPart&, const std::string&, const std::size_t>(), py::arg("model_part"), py::arg("kernel_function_type"), py::arg("max_number_of_neighbours")) | ||
.def("SetFilterRadius", &ExplicitVertexMorphingFilter<TContainerType>::SetFilterRadius, py::arg("filter_radius")) | ||
.def("FilterField", &ExplicitVertexMorphingFilter<TContainerType>::FilterField, py::arg("unfiltered_field")) | ||
.def("FilterIntegratedField", &ExplicitVertexMorphingFilter<TContainerType>::FilterIntegratedField, py::arg("filtered_field")) | ||
.def("Update", &ExplicitVertexMorphingFilter<TContainerType>::Update) | ||
.def("__str__", &ExplicitVertexMorphingFilter<TContainerType>::Info) | ||
; | ||
} | ||
|
||
} // namespace Detail | ||
|
||
void AddCustomFiltersToPython(pybind11::module& m) | ||
{ | ||
Detail::AddExplicitVertexMorphingFilter<ModelPart::NodesContainerType>(m, "NodalExplicitVertexMorphingFilter"); | ||
Detail::AddExplicitVertexMorphingFilter<ModelPart::ConditionsContainerType>(m, "ConditionExplicitVertexMorphingFilter"); | ||
Detail::AddExplicitVertexMorphingFilter<ModelPart::ElementsContainerType>(m, "ElementExplicitVertexMorphingFilter"); | ||
|
||
} | ||
|
||
} // namespace Python. | ||
} // namespace Kratos. |
28 changes: 28 additions & 0 deletions
28
applications/OptimizationApplication/custom_python/add_custom_filters_to_python.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// license: OptimizationApplication/license.txt | ||
// | ||
// Main author: Suneth Warnakulasuriya | ||
// | ||
|
||
#pragma once | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "includes/define_python.h" | ||
|
||
namespace Kratos { | ||
namespace Python { | ||
|
||
void AddCustomFiltersToPython(pybind11::module& m); | ||
|
||
} // namespace Python. | ||
} // namespace Kratos. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
applications/OptimizationApplication/custom_utilities/filtering/entity_point.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// license: OptimizationApplication/license.txt | ||
// | ||
// Main author: Suneth Warnakulasuriya | ||
// | ||
|
||
// System includes | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "geometries/point.h" | ||
#include "includes/model_part.h" | ||
|
||
// Application includes | ||
|
||
// Include base h | ||
#include "entity_point.h" | ||
|
||
namespace Kratos { | ||
|
||
template<class TEntityType> | ||
EntityPoint<TEntityType>::EntityPoint( | ||
const TEntityType& rEntity, | ||
const IndexType Id) | ||
: Point(GetPoint(rEntity)), | ||
mId(Id), | ||
mpEntity(&rEntity) | ||
{ | ||
} | ||
|
||
template<class TEntityType> | ||
IndexType EntityPoint<TEntityType>::Id() const | ||
{ | ||
return mId; | ||
} | ||
|
||
template<class TEntityType> | ||
const TEntityType& EntityPoint<TEntityType>::GetEntity() const | ||
{ | ||
return *mpEntity; | ||
} | ||
|
||
template<class TEntityType> | ||
Point EntityPoint<TEntityType>::GetPoint(const TEntityType& rEntity) | ||
{ | ||
if constexpr(std::is_same_v<TEntityType, ModelPart::NodeType>) { | ||
return rEntity; | ||
} else { | ||
return rEntity.GetGeometry().Center(); | ||
} | ||
} | ||
|
||
//template instantiations | ||
template class EntityPoint<ModelPart::NodeType>; | ||
template class EntityPoint<ModelPart::ConditionType>; | ||
template class EntityPoint<ModelPart::ElementType>; | ||
|
||
} // namespace Kratos |
73 changes: 73 additions & 0 deletions
73
applications/OptimizationApplication/custom_utilities/filtering/entity_point.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// license: OptimizationApplication/license.txt | ||
// | ||
// Main author: Suneth Warnakulasuriya | ||
// | ||
|
||
#pragma once | ||
|
||
// System includes | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "geometries/point.h" | ||
|
||
// Application includes | ||
|
||
namespace Kratos { | ||
|
||
///@name Kratos Classes | ||
///@{ | ||
|
||
template<class TEntityType> | ||
class KRATOS_API(OPTIMIZATION_APPLICATION) EntityPoint : public Point | ||
{ | ||
public: | ||
///@name Type definitions | ||
///@{ | ||
|
||
using EntityType = TEntityType; | ||
|
||
/// Pointer definition of ContainerData | ||
KRATOS_CLASS_POINTER_DEFINITION(EntityPoint); | ||
|
||
///@} | ||
///@name Life cycle | ||
///@{ | ||
|
||
EntityPoint() = default; | ||
|
||
EntityPoint( | ||
const TEntityType& rEntity, | ||
const IndexType Id); | ||
|
||
IndexType Id() const; | ||
|
||
const TEntityType& GetEntity() const; | ||
|
||
///@} | ||
private: | ||
///@name Private member variables | ||
///@{ | ||
|
||
const IndexType mId = 0; | ||
|
||
const TEntityType* mpEntity; | ||
|
||
///@} | ||
///@name Private static methods | ||
///@{ | ||
|
||
static Point GetPoint(const TEntityType& rEntity); | ||
|
||
///@} | ||
}; | ||
|
||
///@} | ||
} // namespace Kratos |
Oops, something went wrong.