From fb8b55a020ff285592307b5436bc62ef399b8efa Mon Sep 17 00:00:00 2001 From: jf remacle <jean-francois.remacle@uclouvain.be> Date: Tue, 14 May 2019 11:47:57 -0400 Subject: [PATCH] added automaticmeshsizefield --- Mesh/CMakeLists.txt | 1 + Mesh/Field.cpp | 2 ++ Mesh/automaticMeshSizeField.cpp | 10 +++++++ Mesh/automaticMeshSizeField.h | 52 +++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 Mesh/automaticMeshSizeField.cpp create mode 100644 Mesh/automaticMeshSizeField.h diff --git a/Mesh/CMakeLists.txt b/Mesh/CMakeLists.txt index e35ef4c599..8be2b1b55c 100644 --- a/Mesh/CMakeLists.txt +++ b/Mesh/CMakeLists.txt @@ -32,6 +32,7 @@ set(SRC Field.cpp filterElements.cpp gmshCrossFields.cpp + automaticMeshSizeField.cpp ) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp index cf2b70633c..af600a0455 100644 --- a/Mesh/Field.cpp +++ b/Mesh/Field.cpp @@ -27,6 +27,7 @@ #include "BackgroundMeshTools.h" #include "STensor3.h" #include "ExtrudeParams.h" +#include "automaticMeshSizeField.h" #include "nanoflann.hpp" #if defined(HAVE_POST) @@ -2956,6 +2957,7 @@ FieldManager::FieldManager() map_type_name["AttractorAnisoCurve"] = new FieldFactoryT<AttractorAnisoCurveField>(); #endif map_type_name["MaxEigenHessian"] = new FieldFactoryT<MaxEigenHessianField>(); + map_type_name["AutomaticMeshSizeField"] = new FieldFactoryT<automaticMeshSizeField>(); _background_field = -1; } diff --git a/Mesh/automaticMeshSizeField.cpp b/Mesh/automaticMeshSizeField.cpp new file mode 100644 index 0000000000..ba9b6159b7 --- /dev/null +++ b/Mesh/automaticMeshSizeField.cpp @@ -0,0 +1,10 @@ +#include "automaticMeshSizeField.h" + + + +double automaticMeshSizeField:: operator()(double X, double Y, double Z, GEntity *ge) { + return _hbulk; +} + +void automaticMeshSizeField:: update(){ +} diff --git a/Mesh/automaticMeshSizeField.h b/Mesh/automaticMeshSizeField.h new file mode 100644 index 0000000000..7178e9ac1d --- /dev/null +++ b/Mesh/automaticMeshSizeField.h @@ -0,0 +1,52 @@ +#ifndef _AUTOMATIC_MESH_SIZE_FIELD_H_ +#define _AUTOMATIC_MESH_SIZE_FIELD_H_ + +#include "Field.h" + +class automaticMeshSizeField : public Field { + + int _nPointsPerCircle; + int _nPointsPerGap; + double _hmin, _hmax; + double _hbulk; + double _gradientMax; + char fileName[256]; + +public: + automaticMeshSizeField() + { + _nPointsPerCircle = 15; + _nPointsPerGap = 5; + _hmin = 1.e-8;// update needed + _hmax = 1.e+8;// update needed + _hbulk = 0.1; // update needed + _gradientMax =1.4; + + + + options["nPointsPerCircle"] = new FieldOptionInt(_nPointsPerCircle, + "Number of points per circle (adapt to curvature of surfaces)"); + + options["nPointsPerGap"] = new FieldOptionInt(_nPointsPerGap, + "Number of points in thin layers"); + + options["hBulk"] = new FieldOptionDouble(_hbulk, + "Size everywhere no size is prescribed", &update_needed); + + options["gradientMax"] = new FieldOptionDouble(_gradientMax, + "Maximun gradient of the size field"); + + } + const char *getName() { return "AutomaticMeshSizeField"; } + + std::string getDescription(){ + return "Compute a mesh size field that is quite automatic " + "Takes into account surface curvatures and closeness of objects"; + } + + void update(); + virtual double operator()(double X, double Y, double Z, GEntity *ge = 0); +}; + + +#endif -- GitLab