add more functions to interface V2 (no global pointer)

This commit is contained in:
Joachim Schöberl 2019-01-14 10:00:11 +01:00
parent ab15ae12bc
commit 9f3e4aaa78
3 changed files with 169 additions and 2 deletions

View File

@ -312,7 +312,7 @@ extern "C" {
struct Ng_SolutionData
{
string name; // name of gridfunction
std::string name; // name of gridfunction
double * data; // solution values
int components; // relevant (double) components in solution vector
int dist; // # doubles per entry alignment!
@ -333,7 +333,7 @@ extern "C" {
// redraw
DLL_HEADER void Ng_Redraw(bool blocking = false);
///
DLL_HEADER void Ng_TclCmd(string cmd);
DLL_HEADER void Ng_TclCmd(std::string cmd);
///
DLL_HEADER void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler);
///

View File

@ -12,6 +12,21 @@
C++ interface to Netgen
*/
#ifndef NGINTERFACE
// implemented element types:
enum NG_ELEMENT_TYPE {
NG_PNT = 0,
NG_SEGM = 1, NG_SEGM3 = 2,
NG_TRIG = 10, NG_QUAD=11, NG_TRIG6 = 12, NG_QUAD6 = 13,
NG_TET = 20, NG_TET10 = 21,
NG_PYRAMID = 22, NG_PRISM = 23, NG_PRISM12 = 24,
NG_HEX = 25
};
enum NG_REFINEMENT_TYPE { NG_REFINE_H = 0, NG_REFINE_P = 1, NG_REFINE_HP = 2 };
#endif
namespace netgen
{
@ -306,7 +321,11 @@ namespace netgen
// 3D only
// std::pair<int,int> GetBoundaryNeighbouringDomains (int bnr);
template <int DIM>
void SetRefinementFlag (size_t elnr, bool flag);
void Curve (int order);
void Refine (NG_REFINEMENT_TYPE reftype,
void (*taskmanager)(function<void(int,int)>) = &DummyTaskManager2,
void (*tracer)(string, bool) = &DummyTracer2);
@ -334,6 +353,27 @@ namespace netgen
shared_ptr<Mesh> GetMesh () const { return mesh; }
shared_ptr<Mesh> SelectMesh () const;
inline auto GetTimeStamp() const;
// also added from nginterface.h, still 1-based, need redesign
void HPRefinement (int levels, double parameter = 0.125,
bool setorders = true,bool ref_level = false);
size_t GetNP() const;
int GetSurfaceElementSurfaceNumber (size_t ei) const;
int GetSurfaceElementFDNumber (size_t ei) const;
int GetElementOrder (int enr) const;
void GetElementOrders (int enr, int * ox, int * oy, int * oz) const;
void SetElementOrder (int enr, int order);
void SetElementOrders (int enr, int ox, int oy, int oz);
int GetSurfaceElementOrder (int enr) const;
void GetSurfaceElementOrders (int enr, int * ox, int * oy) const;
void SetSurfaceElementOrder (int enr, int order);
void SetSurfaceElementOrders (int enr, int ox, int oy);
int GetClusterRepVertex (int vi) const;
int GetClusterRepEdge (int edi) const;
int GetClusterRepFace (int fai) const;
int GetClusterRepElement (int eli) const;
};

View File

@ -1052,6 +1052,19 @@ namespace netgen
NgLock meshlock (mesh->MajorMutex(), true);
mesh->BuildCurvedElements(order);
}
template <>
void Ngx_Mesh :: SetRefinementFlag<2> (size_t elnr, bool flag)
{
mesh->SurfaceElement(elnr+1).SetRefinementFlag(flag);
}
template <>
void Ngx_Mesh :: SetRefinementFlag<3> (size_t elnr, bool flag)
{
mesh->VolumeElement(elnr+1).SetRefinementFlag(flag);
}
void Ngx_Mesh :: Refine (NG_REFINEMENT_TYPE reftype,
void (*task_manager)(function<void(int,int)>),
@ -1080,6 +1093,120 @@ namespace netgen
}
// just copied with redesign
size_t Ngx_Mesh::GetNP() const
{
return mesh->GetNP();
}
int Ngx_Mesh::GetSurfaceElementSurfaceNumber (size_t ei) const
{
if (mesh->GetDimension() == 3)
return mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).SurfNr();
else
return mesh->LineSegment(ei).si;
}
int Ngx_Mesh::GetSurfaceElementFDNumber (size_t ei) const
{
if (mesh->GetDimension() == 3)
return mesh->SurfaceElement(ei).GetIndex();
else
return -1;
}
void Ngx_Mesh::HPRefinement (int levels, double parameter, bool setorders,
bool ref_level)
{
NgLock meshlock (mesh->MajorMutex(), true);
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
::netgen::HPRefinement (*mesh, &ref, levels, parameter, setorders, ref_level);
}
int Ngx_Mesh::GetElementOrder (int enr) const
{
if (mesh->GetDimension() == 3)
return mesh->VolumeElement(enr).GetOrder();
else
return mesh->SurfaceElement(enr).GetOrder();
}
void Ngx_Mesh::GetElementOrders (int enr, int * ox, int * oy, int * oz) const
{
if (mesh->GetDimension() == 3)
mesh->VolumeElement(enr).GetOrder(*ox, *oy, *oz);
else
mesh->SurfaceElement(enr).GetOrder(*ox, *oy, *oz);
}
void Ngx_Mesh::SetElementOrder (int enr, int order)
{
if (mesh->GetDimension() == 3)
return mesh->VolumeElement(enr).SetOrder(order);
else
return mesh->SurfaceElement(enr).SetOrder(order);
}
void Ngx_Mesh::SetElementOrders (int enr, int ox, int oy, int oz)
{
if (mesh->GetDimension() == 3)
mesh->VolumeElement(enr).SetOrder(ox, oy, oz);
else
mesh->SurfaceElement(enr).SetOrder(ox, oy);
}
int Ngx_Mesh::GetSurfaceElementOrder (int enr) const
{
return mesh->SurfaceElement(enr).GetOrder();
}
int Ngx_Mesh::GetClusterRepVertex (int pi) const
{
return mesh->GetClusters().GetVertexRepresentant(pi);
}
int Ngx_Mesh::GetClusterRepEdge (int pi) const
{
return mesh->GetClusters().GetEdgeRepresentant(pi);
}
int Ngx_Mesh::GetClusterRepFace (int pi) const
{
return mesh->GetClusters().GetFaceRepresentant(pi);
}
int Ngx_Mesh::GetClusterRepElement (int pi) const
{
return mesh->GetClusters().GetElementRepresentant(pi);
}
//HERBERT: falsche Anzahl von Argumenten
//void Ngx_Mesh::GetSurfaceElementOrders (int enr, int * ox, int * oy, int * oz)
void Ngx_Mesh::GetSurfaceElementOrders (int enr, int * ox, int * oy) const
{
int d;
mesh->SurfaceElement(enr).GetOrder(*ox, *oy, d);
}
void Ngx_Mesh::SetSurfaceElementOrder (int enr, int order)
{
return mesh->SurfaceElement(enr).SetOrder(order);
}
void Ngx_Mesh::SetSurfaceElementOrders (int enr, int ox, int oy)
{
mesh->SurfaceElement(enr).SetOrder(ox, oy);
}
#ifdef PARALLEL