Commit 12a4bf74 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[io][gmsh] allow granular definitions of geometries to be meshed

One can now set mesh sizes for individual geometries and furthermore,
one can define geometries to be physical or non-physical, depending on
which the interior of the geometries is explicitly meshed or not.
parent 8795dd7d
......@@ -24,7 +24,9 @@
#ifndef FRACKIT_GMSH_FORMAT_BACKEND_HH
#define FRACKIT_GMSH_FORMAT_BACKEND_HH
#include <array>
#include <string>
#include <limits>
#include <cassert>
#include <type_traits>
......@@ -143,7 +145,7 @@ private:
std::string getGeometryKeyword_(unsigned int geomDim) const
{
assert(geomDim <= 3);
static const std::vector<std::string> keywords = {
static const std::array<std::string, 4> keywords = {
"Point", "Curve", "Surface", "Volume"
};
......@@ -160,6 +162,50 @@ private:
int gmshVersion_;
};
namespace Detail {
class MeshSizeVariableNameHelper
{
static constexpr double maxDouble = std::numeric_limits<double>::max();
std::array<std::size_t, 4> counts = {0, 0, 0, 0};
std::array<double, 4> sizes = {maxDouble, maxDouble, maxDouble, maxDouble};
std::array<std::string, 4> names = {"subDomainMeshSize_",
"entityMeshSize_",
"intersectionMeshSize_",
"pointMeshSize_"};
public:
void reset()
{
for (auto& c : counts) c = 0;
for (auto& s : sizes) s = maxDouble;
}
bool prepareNew(unsigned int codim, double size)
{
if (sizes[codim] > size)
{
sizes[codim] = size;
counts[codim]++;
const auto pos = names[codim].find_last_of("_");
const auto suffix = std::to_string(counts[codim]);
const auto suffixLength = suffix.size();
names[codim].resize(pos+1 + suffixLength);
names[codim].replace(pos+1, suffixLength, suffix);
return true;
}
return false;
}
const std::string& get(unsigned int codim)
{ return names[codim]; }
};
} // end namespace Detail
} // end namespace Frackit::Gmsh
#endif // FRACKIT_GMSH_BACKEND_HH
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment