Skip to content
Snippets Groups Projects
Commit bce81183 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Merge branch 'feature/zone-name-and-tag' into 'develop'

Displace NamedBoundaryDescriptor and NumberedBoundaryDescriptor

See merge request !136
parents c1afdb4a 1a92abef
Branches
Tags
1 merge request!136Displace NamedBoundaryDescriptor and NumberedBoundaryDescriptor
Showing
with 306 additions and 78 deletions
......@@ -10,9 +10,15 @@
#include <mesh/Connectivity.hpp>
#include <mesh/DualMeshManager.hpp>
#include <mesh/GmshReader.hpp>
#include <mesh/IBoundaryDescriptor.hpp>
#include <mesh/IZoneDescriptor.hpp>
#include <mesh/Mesh.hpp>
#include <mesh/MeshRelaxer.hpp>
#include <mesh/MeshTransformer.hpp>
#include <mesh/NamedBoundaryDescriptor.hpp>
#include <mesh/NamedZoneDescriptor.hpp>
#include <mesh/NumberedBoundaryDescriptor.hpp>
#include <mesh/NumberedZoneDescriptor.hpp>
#include <utils/Exceptions.hpp>
#include <Kokkos_Core.hpp>
......@@ -31,6 +37,45 @@ MeshModule::MeshModule()
));
this->_addBuiltinFunction("boundaryName",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IBoundaryDescriptor>(const std::string&)>>(
[](const std::string& boundary_name) -> std::shared_ptr<const IBoundaryDescriptor> {
return std::make_shared<NamedBoundaryDescriptor>(boundary_name);
}
));
this->_addBuiltinFunction("zoneTag",
std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr<const IZoneDescriptor>(int64_t)>>(
[](int64_t zone_tag) -> std::shared_ptr<const IZoneDescriptor> {
return std::make_shared<NumberedZoneDescriptor>(zone_tag);
}
));
this->_addBuiltinFunction("zoneName",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IZoneDescriptor>(const std::string&)>>(
[](const std::string& zone_name) -> std::shared_ptr<const IZoneDescriptor> {
return std::make_shared<NamedZoneDescriptor>(zone_name);
}
));
this->_addBuiltinFunction("boundaryTag",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IBoundaryDescriptor>(int64_t)>>(
[](int64_t boundary_tag) -> std::shared_ptr<const IBoundaryDescriptor> {
return std::make_shared<NumberedBoundaryDescriptor>(boundary_tag);
}
));
this->_addBuiltinFunction("transform",
std::make_shared<BuiltinFunctionEmbedder<
std::shared_ptr<const IMesh>(std::shared_ptr<const IMesh>, const FunctionSymbolId&)>>(
......
......@@ -6,11 +6,20 @@
#include <utils/PugsMacros.hpp>
class IMesh;
template <>
inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const IMesh>> =
ASTNodeDataType::build<ASTNodeDataType::type_id_t>("mesh");
class IBoundaryDescriptor;
template <>
inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const IBoundaryDescriptor>> =
ASTNodeDataType::build<ASTNodeDataType::type_id_t>("boundary");
class IZoneDescriptor;
template <>
inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const IZoneDescriptor>> =
ASTNodeDataType::build<ASTNodeDataType::type_id_t>("zone");
class MeshModule : public BuiltinModule
{
public:
......
......@@ -33,9 +33,7 @@
#include <scheme/IBoundaryConditionDescriptor.hpp>
#include <scheme/IDiscreteFunction.hpp>
#include <scheme/IDiscreteFunctionDescriptor.hpp>
#include <scheme/NamedBoundaryDescriptor.hpp>
#include <scheme/NeumannBoundaryConditionDescriptor.hpp>
#include <scheme/NumberedBoundaryDescriptor.hpp>
#include <scheme/SymmetryBoundaryConditionDescriptor.hpp>
#include <utils/Socket.hpp>
......@@ -191,26 +189,6 @@ SchemeModule::SchemeModule()
));
this->_addBuiltinFunction("boundaryName",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IBoundaryDescriptor>(const std::string&)>>(
[](const std::string& boundary_name) -> std::shared_ptr<const IBoundaryDescriptor> {
return std::make_shared<NamedBoundaryDescriptor>(boundary_name);
}
));
this->_addBuiltinFunction("boundaryTag",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IBoundaryDescriptor>(int64_t)>>(
[](int64_t boundary_tag) -> std::shared_ptr<const IBoundaryDescriptor> {
return std::make_shared<NumberedBoundaryDescriptor>(boundary_tag);
}
));
this
->_addBuiltinFunction("fixed",
std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr<const IBoundaryConditionDescriptor>(
......
......@@ -5,11 +5,6 @@
#include <language/utils/ASTNodeDataTypeTraits.hpp>
#include <utils/PugsMacros.hpp>
class IBoundaryDescriptor;
template <>
inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const IBoundaryDescriptor>> =
ASTNodeDataType::build<ASTNodeDataType::type_id_t>("boundary");
class IBoundaryConditionDescriptor;
template <>
inline ASTNodeDataType ast_node_data_type_from<std::shared_ptr<const IBoundaryConditionDescriptor>> =
......
......@@ -19,18 +19,20 @@ class IBoundaryDescriptor
public:
friend std::ostream&
operator<<(std::ostream& os, const IBoundaryDescriptor& bd)
operator<<(std::ostream& os, const IBoundaryDescriptor& boundary_descriptor)
{
return bd._write(os);
return boundary_descriptor._write(os);
}
virtual bool operator==(const RefId& ref_id) const = 0;
friend bool
operator==(const RefId& ref_id, const IBoundaryDescriptor& bcd)
[[nodiscard]] virtual bool operator==(const RefId& ref_id) const = 0;
[[nodiscard]] friend bool
operator==(const RefId& ref_id, const IBoundaryDescriptor& boundary_descriptor)
{
return bcd == ref_id;
return boundary_descriptor == ref_id;
}
virtual Type type() const = 0;
[[nodiscard]] virtual Type type() const = 0;
IBoundaryDescriptor(const IBoundaryDescriptor&) = delete;
IBoundaryDescriptor(IBoundaryDescriptor&&) = delete;
......@@ -38,4 +40,5 @@ class IBoundaryDescriptor
virtual ~IBoundaryDescriptor() = default;
};
#endif // I_BOUNDARY_DESCRIPTOR_HPP
#ifndef I_ZONE_DESCRIPTOR_HPP
#define I_ZONE_DESCRIPTOR_HPP
#include <mesh/RefId.hpp>
#include <iostream>
class IZoneDescriptor
{
public:
enum class Type
{
named,
numbered
};
protected:
virtual std::ostream& _write(std::ostream& os) const = 0;
public:
friend std::ostream&
operator<<(std::ostream& os, const IZoneDescriptor& zone_descriptor)
{
return zone_descriptor._write(os);
}
[[nodiscard]] virtual bool operator==(const RefId& ref_id) const = 0;
[[nodiscard]] friend bool
operator==(const RefId& ref_id, const IZoneDescriptor& zone_descriptor)
{
return zone_descriptor == ref_id;
}
[[nodiscard]] virtual Type type() const = 0;
IZoneDescriptor(const IZoneDescriptor&) = delete;
IZoneDescriptor(IZoneDescriptor&&) = delete;
IZoneDescriptor() = default;
virtual ~IZoneDescriptor() = default;
};
#endif // I_ZONE_DESCRIPTOR_HPP
#include <mesh/MeshCellZone.hpp>
#include <mesh/Connectivity.hpp>
#include <mesh/Mesh.hpp>
#include <utils/Messenger.hpp>
template <size_t Dimension>
MeshCellZone<Dimension>::MeshCellZone(const Mesh<Connectivity<Dimension>>&, const RefCellList& ref_cell_list)
: m_cell_list(ref_cell_list.list()), m_zone_name(ref_cell_list.refId().tagName())
{}
template MeshCellZone<2>::MeshCellZone(const Mesh<Connectivity<2>>&, const RefCellList&);
template MeshCellZone<3>::MeshCellZone(const Mesh<Connectivity<3>>&, const RefCellList&);
template <size_t Dimension>
MeshCellZone<Dimension>
getMeshCellZone(const Mesh<Connectivity<Dimension>>& mesh, const IZoneDescriptor& zone_descriptor)
{
for (size_t i_ref_cell_list = 0; i_ref_cell_list < mesh.connectivity().template numberOfRefItemList<ItemType::cell>();
++i_ref_cell_list) {
const auto& ref_cell_list = mesh.connectivity().template refItemList<ItemType::cell>(i_ref_cell_list);
const RefId& ref = ref_cell_list.refId();
if (ref == zone_descriptor) {
return MeshCellZone<Dimension>{mesh, ref_cell_list};
}
}
std::ostringstream ost;
ost << "cannot find zone with name " << rang::fgB::red << zone_descriptor << rang::style::reset;
throw NormalError(ost.str());
}
template MeshCellZone<1> getMeshCellZone(const Mesh<Connectivity<1>>&, const IZoneDescriptor&);
template MeshCellZone<2> getMeshCellZone(const Mesh<Connectivity<2>>&, const IZoneDescriptor&);
template MeshCellZone<3> getMeshCellZone(const Mesh<Connectivity<3>>&, const IZoneDescriptor&);
#ifndef MESH_CELL_ZONE_HPP
#define MESH_CELL_ZONE_HPP
#include <mesh/IZoneDescriptor.hpp>
#include <mesh/RefItemList.hpp>
#include <utils/Array.hpp>
template <size_t Dimension>
class Connectivity;
template <typename ConnectivityType>
class Mesh;
template <size_t Dimension>
class [[nodiscard]] MeshCellZone // clazy:exclude=copyable-polymorphic
{
protected:
Array<const CellId> m_cell_list;
std::string m_zone_name;
public:
template <size_t MeshDimension>
friend MeshCellZone<MeshDimension> getMeshCellZone(const Mesh<Connectivity<MeshDimension>>& mesh,
const IZoneDescriptor& zone_descriptor);
MeshCellZone& operator=(const MeshCellZone&) = default;
MeshCellZone& operator=(MeshCellZone&&) = default;
const Array<const CellId>& cellList() const
{
return m_cell_list;
}
protected:
MeshCellZone(const Mesh<Connectivity<Dimension>>& mesh, const RefCellList& ref_cell_list);
public:
MeshCellZone(const MeshCellZone&) = default;
MeshCellZone(MeshCellZone &&) = default;
MeshCellZone() = default;
virtual ~MeshCellZone() = default;
};
template <size_t Dimension>
MeshCellZone<Dimension> getMeshCellZone(const Mesh<Connectivity<Dimension>>& mesh,
const IZoneDescriptor& zone_descriptor);
#endif // MESH_CELL_ZONE_HPP
......@@ -3,7 +3,6 @@
#include <algebra/TinyVector.hpp>
#include <mesh/IBoundaryDescriptor.hpp>
#include <mesh/ItemValue.hpp>
#include <mesh/RefItemList.hpp>
#include <utils/Array.hpp>
......@@ -14,14 +13,14 @@ template <typename ConnectivityType>
class Mesh;
template <size_t Dimension>
class MeshFaceBoundary // clazy:exclude=copyable-polymorphic
class [[nodiscard]] MeshFaceBoundary // clazy:exclude=copyable-polymorphic
{
protected:
Array<const FaceId> m_face_list;
std::string m_boundary_name;
std::array<TinyVector<Dimension>, Dimension*(Dimension - 1)> _getBounds(
const Mesh<Connectivity<Dimension>>& mesh) const;
std::array<TinyVector<Dimension>, Dimension*(Dimension - 1)> _getBounds(const Mesh<Connectivity<Dimension>>& mesh)
const;
public:
template <size_t MeshDimension>
......@@ -31,8 +30,7 @@ class MeshFaceBoundary // clazy:exclude=copyable-polymorphic
MeshFaceBoundary& operator=(const MeshFaceBoundary&) = default;
MeshFaceBoundary& operator=(MeshFaceBoundary&&) = default;
const Array<const FaceId>&
faceList() const
const Array<const FaceId>& faceList() const
{
return m_face_list;
}
......
......@@ -4,7 +4,8 @@
#include <mesh/MeshNodeBoundary.hpp>
template <size_t Dimension>
class MeshFlatNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy:exclude=copyable-polymorphic
class [[nodiscard]] MeshFlatNodeBoundary final
: public MeshNodeBoundary<Dimension> // clazy:exclude=copyable-polymorphic
{
public:
using Rd = TinyVector<Dimension, double>;
......@@ -14,16 +15,13 @@ class MeshFlatNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy
Rd _getNormal(const Mesh<Connectivity<Dimension>>& mesh);
void _checkBoundaryIsFlat(const TinyVector<Dimension, double>& normal,
const TinyVector<Dimension, double>& origin,
const double length,
const Mesh<Connectivity<Dimension>>& mesh) const;
void _checkBoundaryIsFlat(const TinyVector<Dimension, double>& normal, const TinyVector<Dimension, double>& origin,
const double length, const Mesh<Connectivity<Dimension>>& mesh) const;
Rd _getOutgoingNormal(const Mesh<Connectivity<Dimension>>& mesh);
public:
const Rd&
outgoingNormal() const
const Rd& outgoingNormal() const
{
return m_outgoing_normal;
}
......
......@@ -5,7 +5,8 @@
#include <mesh/MeshNodeBoundary.hpp>
template <size_t Dimension>
class MeshLineNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy:exclude=copyable-polymorphic
class [[nodiscard]] MeshLineNodeBoundary final
: public MeshNodeBoundary<Dimension> // clazy:exclude=copyable-polymorphic
{
public:
using Rd = TinyVector<Dimension, double>;
......@@ -16,10 +17,8 @@ class MeshLineNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy
template <size_t MeshDimension>
TinyVector<MeshDimension> _getDirection(const Mesh<Connectivity<MeshDimension>>&);
void _checkBoundaryIsLine(const TinyVector<Dimension, double>& direction,
const TinyVector<Dimension, double>& origin,
const double length,
const Mesh<Connectivity<Dimension>>& mesh) const;
void _checkBoundaryIsLine(const TinyVector<Dimension, double>& direction, const TinyVector<Dimension, double>& origin,
const double length, const Mesh<Connectivity<Dimension>>& mesh) const;
public:
template <size_t MeshDimension>
......@@ -27,8 +26,7 @@ class MeshLineNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy
const IBoundaryDescriptor& boundary_descriptor);
PUGS_INLINE
const Rd&
direction() const
const Rd& direction() const
{
return m_direction;
}
......@@ -39,9 +37,7 @@ class MeshLineNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy
private:
MeshLineNodeBoundary(const Mesh<Connectivity<Dimension>>& mesh, const RefEdgeList& ref_edge_list)
: MeshNodeBoundary<Dimension>(mesh, ref_edge_list), m_direction(_getDirection(mesh))
{
;
}
{}
MeshLineNodeBoundary(const Mesh<Connectivity<Dimension>>& mesh, const RefFaceList& ref_face_list)
: MeshNodeBoundary<Dimension>(mesh, ref_face_list), m_direction(_getDirection(mesh))
......
......@@ -3,7 +3,6 @@
#include <algebra/TinyVector.hpp>
#include <mesh/IBoundaryDescriptor.hpp>
#include <mesh/ItemValue.hpp>
#include <mesh/RefItemList.hpp>
#include <utils/Array.hpp>
......@@ -14,14 +13,14 @@ template <typename ConnectivityType>
class Mesh;
template <size_t Dimension>
class MeshNodeBoundary // clazy:exclude=copyable-polymorphic
class [[nodiscard]] MeshNodeBoundary // clazy:exclude=copyable-polymorphic
{
protected:
Array<const NodeId> m_node_list;
std::string m_boundary_name;
std::array<TinyVector<Dimension>, Dimension*(Dimension - 1)> _getBounds(
const Mesh<Connectivity<Dimension>>& mesh) const;
std::array<TinyVector<Dimension>, Dimension*(Dimension - 1)> _getBounds(const Mesh<Connectivity<Dimension>>& mesh)
const;
public:
template <size_t MeshDimension>
......@@ -31,8 +30,7 @@ class MeshNodeBoundary // clazy:exclude=copyable-polymorphic
MeshNodeBoundary& operator=(const MeshNodeBoundary&) = default;
MeshNodeBoundary& operator=(MeshNodeBoundary&&) = default;
const Array<const NodeId>&
nodeList() const
const Array<const NodeId>& nodeList() const
{
return m_node_list;
}
......
......@@ -6,7 +6,7 @@
#include <iostream>
#include <string>
class NamedBoundaryDescriptor : public IBoundaryDescriptor
class NamedBoundaryDescriptor final : public IBoundaryDescriptor
{
private:
std::string m_name;
......@@ -19,13 +19,13 @@ class NamedBoundaryDescriptor : public IBoundaryDescriptor
}
public:
bool
[[nodiscard]] bool
operator==(const RefId& ref_id) const final
{
return m_name == ref_id.tagName();
}
Type
[[nodiscard]] Type
type() const final
{
return Type::named;
......@@ -33,10 +33,7 @@ class NamedBoundaryDescriptor : public IBoundaryDescriptor
NamedBoundaryDescriptor(const NamedBoundaryDescriptor&) = delete;
NamedBoundaryDescriptor(NamedBoundaryDescriptor&&) = delete;
NamedBoundaryDescriptor(const std::string& name) : m_name(name)
{
;
}
NamedBoundaryDescriptor(const std::string& name) : m_name(name) {}
virtual ~NamedBoundaryDescriptor() = default;
};
......
#ifndef NAMED_ZONE_DESCRIPTOR_HPP
#define NAMED_ZONE_DESCRIPTOR_HPP
#include <mesh/IZoneDescriptor.hpp>
#include <iostream>
#include <string>
class NamedZoneDescriptor final : public IZoneDescriptor
{
private:
std::string m_name;
std::ostream&
_write(std::ostream& os) const final
{
os << '"' << m_name << '"';
return os;
}
public:
bool
operator==(const RefId& ref_id) const final
{
return m_name == ref_id.tagName();
}
Type
type() const final
{
return Type::named;
}
NamedZoneDescriptor(const NamedZoneDescriptor&) = delete;
NamedZoneDescriptor(NamedZoneDescriptor&&) = delete;
NamedZoneDescriptor(const std::string& name) : m_name(name)
{
;
}
virtual ~NamedZoneDescriptor() = default;
};
#endif // NAMED_ZONE_DESCRIPTOR_HPP
......@@ -5,7 +5,7 @@
#include <iostream>
class NumberedBoundaryDescriptor : public IBoundaryDescriptor
class NumberedBoundaryDescriptor final : public IBoundaryDescriptor
{
private:
unsigned int m_number;
......@@ -17,14 +17,14 @@ class NumberedBoundaryDescriptor : public IBoundaryDescriptor
return os;
}
bool
[[nodiscard]] bool
operator==(const RefId& ref_id) const final
{
return m_number == ref_id.tagNumber();
}
public:
Type
[[nodiscard]] Type
type() const final
{
return Type::numbered;
......
#ifndef NUMBERED_ZONE_DESCRIPTOR_HPP
#define NUMBERED_ZONE_DESCRIPTOR_HPP
#include <mesh/IZoneDescriptor.hpp>
#include <iostream>
class NumberedZoneDescriptor final : public IZoneDescriptor
{
private:
unsigned int m_number;
std::ostream&
_write(std::ostream& os) const final
{
os << '"' << m_number << '"';
return os;
}
bool
operator==(const RefId& ref_id) const final
{
return m_number == ref_id.tagNumber();
}
public:
Type
type() const final
{
return Type::numbered;
}
NumberedZoneDescriptor(const NumberedZoneDescriptor&) = delete;
NumberedZoneDescriptor(NumberedZoneDescriptor&&) = delete;
NumberedZoneDescriptor(unsigned int number) : m_number(number) {}
virtual ~NumberedZoneDescriptor() = default;
};
#endif // NUMBERED_ZONE_DESCRIPTOR_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment