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

Check that discrete functions are defined on the mesh to smooth

parent f25b9639
Branches
Tags
1 merge request!167Improve fluxing based remapping
...@@ -246,7 +246,7 @@ SchemeModule::SchemeModule() ...@@ -246,7 +246,7 @@ SchemeModule::SchemeModule()
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>&
bc_descriptor_list) -> std::shared_ptr<const IMesh> { bc_descriptor_list) -> std::shared_ptr<const IMesh> {
MeshSmootherHandler handler; MeshSmootherHandler handler;
return handler.getSmoothedMesh(*p_mesh, bc_descriptor_list); return handler.getSmoothedMesh(p_mesh, bc_descriptor_list);
} }
)); ));
...@@ -259,7 +259,7 @@ SchemeModule::SchemeModule() ...@@ -259,7 +259,7 @@ SchemeModule::SchemeModule()
bc_descriptor_list, bc_descriptor_list,
const FunctionSymbolId& function_symbol_id) -> std::shared_ptr<const IMesh> { const FunctionSymbolId& function_symbol_id) -> std::shared_ptr<const IMesh> {
MeshSmootherHandler handler; MeshSmootherHandler handler;
return handler.getSmoothedMesh(*p_mesh, bc_descriptor_list, function_symbol_id); return handler.getSmoothedMesh(p_mesh, bc_descriptor_list, function_symbol_id);
} }
)); ));
...@@ -273,7 +273,7 @@ SchemeModule::SchemeModule() ...@@ -273,7 +273,7 @@ SchemeModule::SchemeModule()
const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list) const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list)
-> std::shared_ptr<const IMesh> { -> std::shared_ptr<const IMesh> {
MeshSmootherHandler handler; MeshSmootherHandler handler;
return handler.getSmoothedMesh(*p_mesh, bc_descriptor_list, smoothing_zone_list); return handler.getSmoothedMesh(p_mesh, bc_descriptor_list, smoothing_zone_list);
} }
)); ));
...@@ -286,7 +286,7 @@ SchemeModule::SchemeModule() ...@@ -286,7 +286,7 @@ SchemeModule::SchemeModule()
const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>& const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>&
discrete_function_variant_list) -> std::shared_ptr<const IMesh> { discrete_function_variant_list) -> std::shared_ptr<const IMesh> {
MeshSmootherHandler handler; MeshSmootherHandler handler;
return handler.getSmoothedMesh(*p_mesh, bc_descriptor_list, return handler.getSmoothedMesh(p_mesh, bc_descriptor_list,
discrete_function_variant_list); discrete_function_variant_list);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <mesh/MeshLineNodeBoundary.hpp> #include <mesh/MeshLineNodeBoundary.hpp>
#include <mesh/MeshNodeBoundary.hpp> #include <mesh/MeshNodeBoundary.hpp>
#include <scheme/AxisBoundaryConditionDescriptor.hpp> #include <scheme/AxisBoundaryConditionDescriptor.hpp>
#include <scheme/DiscreteFunctionUtils.hpp>
#include <scheme/DiscreteFunctionVariant.hpp> #include <scheme/DiscreteFunctionVariant.hpp>
#include <scheme/FixedBoundaryConditionDescriptor.hpp> #include <scheme/FixedBoundaryConditionDescriptor.hpp>
#include <scheme/SymmetryBoundaryConditionDescriptor.hpp> #include <scheme/SymmetryBoundaryConditionDescriptor.hpp>
...@@ -408,26 +409,26 @@ class MeshSmootherHandler::MeshSmoother<Dimension>::SymmetryBoundaryCondition ...@@ -408,26 +409,26 @@ class MeshSmootherHandler::MeshSmoother<Dimension>::SymmetryBoundaryCondition
std::shared_ptr<const IMesh> std::shared_ptr<const IMesh>
MeshSmootherHandler::getSmoothedMesh( MeshSmootherHandler::getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list) const const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list) const
{ {
switch (mesh.dimension()) { switch (mesh->dimension()) {
case 1: { case 1: {
constexpr size_t Dimension = 1; constexpr size_t Dimension = 1;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(); return smoother.getSmoothedMesh();
} }
case 2: { case 2: {
constexpr size_t Dimension = 2; constexpr size_t Dimension = 2;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(); return smoother.getSmoothedMesh();
} }
case 3: { case 3: {
constexpr size_t Dimension = 3; constexpr size_t Dimension = 3;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(); return smoother.getSmoothedMesh();
} }
default: { default: {
...@@ -438,27 +439,27 @@ MeshSmootherHandler::getSmoothedMesh( ...@@ -438,27 +439,27 @@ MeshSmootherHandler::getSmoothedMesh(
std::shared_ptr<const IMesh> std::shared_ptr<const IMesh>
MeshSmootherHandler::getSmoothedMesh( MeshSmootherHandler::getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const FunctionSymbolId& function_symbol_id) const const FunctionSymbolId& function_symbol_id) const
{ {
switch (mesh.dimension()) { switch (mesh->dimension()) {
case 1: { case 1: {
constexpr size_t Dimension = 1; constexpr size_t Dimension = 1;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(function_symbol_id); return smoother.getSmoothedMesh(function_symbol_id);
} }
case 2: { case 2: {
constexpr size_t Dimension = 2; constexpr size_t Dimension = 2;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(function_symbol_id); return smoother.getSmoothedMesh(function_symbol_id);
} }
case 3: { case 3: {
constexpr size_t Dimension = 3; constexpr size_t Dimension = 3;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(function_symbol_id); return smoother.getSmoothedMesh(function_symbol_id);
} }
default: { default: {
...@@ -469,27 +470,27 @@ MeshSmootherHandler::getSmoothedMesh( ...@@ -469,27 +470,27 @@ MeshSmootherHandler::getSmoothedMesh(
std::shared_ptr<const IMesh> std::shared_ptr<const IMesh>
MeshSmootherHandler::getSmoothedMesh( MeshSmootherHandler::getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list) const const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list) const
{ {
switch (mesh.dimension()) { switch (mesh->dimension()) {
case 1: { case 1: {
constexpr size_t Dimension = 1; constexpr size_t Dimension = 1;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(smoothing_zone_list); return smoother.getSmoothedMesh(smoothing_zone_list);
} }
case 2: { case 2: {
constexpr size_t Dimension = 2; constexpr size_t Dimension = 2;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(smoothing_zone_list); return smoother.getSmoothedMesh(smoothing_zone_list);
} }
case 3: { case 3: {
constexpr size_t Dimension = 3; constexpr size_t Dimension = 3;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(smoothing_zone_list); return smoother.getSmoothedMesh(smoothing_zone_list);
} }
default: { default: {
...@@ -500,27 +501,37 @@ MeshSmootherHandler::getSmoothedMesh( ...@@ -500,27 +501,37 @@ MeshSmootherHandler::getSmoothedMesh(
std::shared_ptr<const IMesh> std::shared_ptr<const IMesh>
MeshSmootherHandler::getSmoothedMesh( MeshSmootherHandler::getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>& discrete_function_variant_list) const const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>& discrete_function_variant_list) const
{ {
switch (mesh.dimension()) { if (not hasSameMesh(discrete_function_variant_list)) {
throw NormalError("discrete functions are not defined on the same mesh");
}
std::shared_ptr<const IMesh> common_mesh = getCommonMesh(discrete_function_variant_list);
if (common_mesh != mesh) {
throw NormalError("discrete functions are not defined on the smoothed mesh");
}
switch (mesh->dimension()) {
case 1: { case 1: {
constexpr size_t Dimension = 1; constexpr size_t Dimension = 1;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(discrete_function_variant_list); return smoother.getSmoothedMesh(discrete_function_variant_list);
} }
case 2: { case 2: {
constexpr size_t Dimension = 2; constexpr size_t Dimension = 2;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(discrete_function_variant_list); return smoother.getSmoothedMesh(discrete_function_variant_list);
} }
case 3: { case 3: {
constexpr size_t Dimension = 3; constexpr size_t Dimension = 3;
using MeshType = Mesh<Connectivity<Dimension>>; using MeshType = Mesh<Connectivity<Dimension>>;
MeshSmoother smoother(dynamic_cast<const MeshType&>(mesh), bc_descriptor_list); MeshSmoother smoother(dynamic_cast<const MeshType&>(*mesh), bc_descriptor_list);
return smoother.getSmoothedMesh(discrete_function_variant_list); return smoother.getSmoothedMesh(discrete_function_variant_list);
} }
default: { default: {
......
...@@ -19,21 +19,21 @@ class MeshSmootherHandler ...@@ -19,21 +19,21 @@ class MeshSmootherHandler
public: public:
std::shared_ptr<const IMesh> getSmoothedMesh( std::shared_ptr<const IMesh> getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list) const; const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list) const;
std::shared_ptr<const IMesh> getSmoothedMesh( std::shared_ptr<const IMesh> getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const FunctionSymbolId& function_symbol_id) const; const FunctionSymbolId& function_symbol_id) const;
std::shared_ptr<const IMesh> getSmoothedMesh( std::shared_ptr<const IMesh> getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list) const; const std::vector<std::shared_ptr<const IZoneDescriptor>>& smoothing_zone_list) const;
std::shared_ptr<const IMesh> getSmoothedMesh( std::shared_ptr<const IMesh> getSmoothedMesh(
const IMesh& mesh, const std::shared_ptr<const IMesh>& mesh,
const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list, const std::vector<std::shared_ptr<const IBoundaryConditionDescriptor>>& bc_descriptor_list,
const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>& smoothing_zone_list) const; const std::vector<std::shared_ptr<const DiscreteFunctionVariant>>& smoothing_zone_list) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment