File: boundarylayer.hpp

package info (click to toggle)
netgen 6.2.2601%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,076 kB
  • sloc: cpp: 166,627; tcl: 6,310; python: 2,868; sh: 528; makefile: 90
file content (113 lines) | stat: -rw-r--r-- 3,476 bytes parent folder | download | duplicates (3)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef NETGEN_BOUNDARYLAYER_HPP
#define NETGEN_BOUNDARYLAYER_HPP

#include <core/array.hpp>
#include <mystdlib.h>
#include <meshing.hpp>

namespace netgen
{

///
DLL_HEADER extern void InsertVirtualBoundaryLayer (Mesh& mesh);

/// Create a typical prismatic boundary layer on the given
/// surfaces

struct SpecialBoundaryPoint
{
  struct GrowthGroup
  {
    Array<int> faces;
    Vec<3> growth_vector;
    Array<PointIndex> new_points;

    GrowthGroup (FlatArray<int> faces_, FlatArray<Vec<3>> normals);
    GrowthGroup (const GrowthGroup&) = default;
    GrowthGroup () = default;
  };
  Array<GrowthGroup> growth_groups;
  Vec<3> separating_direction;

  SpecialBoundaryPoint (const std::map<int, Vec<3>>& normals);
  SpecialBoundaryPoint () = default;
};

DLL_HEADER void GenerateBoundaryLayer (Mesh& mesh,
                                       const BoundaryLayerParameters& blp);

DLL_HEADER int /* new_domain_number */ GenerateBoundaryLayer2 (Mesh& mesh, int domain, const Array<double>& thicknesses, bool should_make_new_domain = true, const Array<int>& boundaries = Array<int>{});

class BoundaryLayerTool
{
public:
  BoundaryLayerTool (Mesh& mesh_, const BoundaryLayerParameters& params_);
  void ProcessParameters ();
  void Perform ();

  Mesh& mesh;
  MeshTopology& topo;
  BoundaryLayerParameters params;
  Array<Vec<3>, PointIndex> growthvectors;
  std::map<PointIndex, Vec<3>> non_bl_growth_vectors;
  Table<SurfaceElementIndex, PointIndex> p2sel;

  BitArray domains, is_edge_moved, is_boundary_projected, is_boundary_moved;
  Array<SegmentIndex> moved_segs;
  int max_edge_nr, nfd_old, ndom_old;
  Array<int> new_mat_nrs;
  BitArray moved_surfaces;
  int np, nseg, nse, ne;
  PointIndex first_new_pi;
  double total_height;
  Array<POINTTYPE, PointIndex> point_types;

  // These parameters are derived from given BoundaryLayerParameters and the Mesh
  Array<double> par_heights;
  Array<int> par_surfid;
  bool insert_only_volume_elements;
  map<string, string> par_new_mat;
  bool have_material_map = false;
  Array<size_t> par_project_boundaries;

  bool have_single_segments;
  Array<Segment> old_segments, free_segments, segments, new_segments, new_segments_on_moved_bnd;
  Array<Element2d, SurfaceElementIndex> new_sels, new_sels_on_moved_bnd;
  Array<Array<PointIndex>, PointIndex> mapto;
  Array<PointIndex, PointIndex> mapfrom;

  Array<double> surfacefacs;
  Array<int> si_map;

  std::map<PointIndex, SpecialBoundaryPoint> special_boundary_points;
  std::map<PointIndex, std::tuple<Vec<3>*, double>> growth_vector_map;

  // major steps called in Perform()
  void CreateNewFaceDescriptors ();
  void CreateFaceDescriptorsSides ();
  void CalculateGrowthVectors ();
  Array<Array<pair<SegmentIndex, int>>, SegmentIndex> BuildSegMap ();

  BitArray ProjectGrowthVectorsOnSurface ();
  void InterpolateSurfaceGrowthVectors ();
  void InterpolateGrowthVectors ();
  void LimitGrowthVectorLengths ();
  void FixSurfaceElements ();

  void InsertNewElements (FlatArray<Array<pair<SegmentIndex, int>>, SegmentIndex> segmap, const BitArray& in_surface_direction);
  void SetDomInOut ();
  void SetDomInOutSides ();
  void AddSegments ();
  void AddSurfaceElements ();

  Vec<3> getNormal (const Element2d& el)
  {
    auto v0 = mesh[el[0]];
    return Cross(mesh[el[1]] - v0, mesh[el[2]] - v0).Normalize();
  }

  Vec<3> getEdgeTangent (PointIndex pi, int edgenr, FlatArray<Segment*> segs);
};

} // namespace netgen
#endif // NETGEN_BOUNDARYLAYER_HPP