-
Notifications
You must be signed in to change notification settings - Fork 4
/
meshUtils.h
41 lines (37 loc) · 1.44 KB
/
meshUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <gmsh.h>
/**
convenient template to check elements type while reading a gmsh mesh file
*/
template <int TYPE>
bool all_elems_are(std::vector<int> &container)
{ return std::all_of(container.begin(), container.end(), [](int &e_type){return e_type == TYPE;} ); }
/**
convenient template to check named regions(volume or surface) from feellgood settings exist in physical groups gmsh mesh inner structure built from file
*/
template <class T>
bool checkNamedObjects(std::vector<T> const &v_prm, const int dim_obj)
{
bool existRegions(true);
std::vector<std::pair<int, int> > physGroups;
gmsh::model::getPhysicalGroups(physGroups,dim_obj);
std::vector<std::string> o_names;
std::for_each(physGroups.begin(),physGroups.end(),[&o_names]( std::pair<int, int> &pGroup)
{
std::string physGroupName;
gmsh::model::getPhysicalName(pGroup.first, pGroup.second, physGroupName);
o_names.push_back(physGroupName);
});
std::for_each(v_prm.begin(),v_prm.end(),[&existRegions,&o_names](auto p)
{
if (p.regName != "__default__")
{
if (!std::any_of(o_names.begin(),o_names.end(),
[&p] (std::string &elem) { return p.regName == elem; } ) )
{
std::cout << "Fatal Error: region " << p.regName << " not found.\n";
existRegions = false;
}
}
} );
return existRegions;
}