setting bboundary names

This commit is contained in:
Christopher Lackner 2016-10-05 19:48:18 +02:00
parent a4fe0c1c41
commit 6134717796
8 changed files with 53 additions and 20 deletions

View File

@ -485,7 +485,18 @@ namespace netgen
layer,
mesh);
}
(*testout) << "refedges size: " << refedges.Size() << endl;
for(int i=0; i<refedges.Size(); i++)
{
(*testout) << "edgenr: " << refedges[i].edgenr << endl;
auto splinesurface = dynamic_cast<const SplineSurface*>(geometry.GetSurface(refedges[i].surfnr1));
if(splinesurface)
{
auto name = splinesurface->GetBCNameOf(specpoints[startpoints.Get(refedges[i].edgenr)].p,specpoints[endpoints.Get(refedges[i].edgenr)].p);
mesh.SetCD2Name(refedges[i].edgenr-1,*name);
}
}
/*
// not available ...

View File

@ -339,21 +339,6 @@ namespace netgen
fd.SetBCName ( mesh.GetBCNamePtr ( fd.BCProperty() - 1 ) );
}
int bbccnt = 0;
for (int k = 0; k < geom.GetNSurf(); k++){
auto splinesurf = dynamic_cast<const SplineSurface*> (geom.GetSurface(k));
if (splinesurf)
{
for( int i=0; i< splinesurf->GetNSplines(); i++)
{
string bcname = *splinesurf->GetBCName(i);
if(bcname != "default"){
mesh.SetCD2Name(bbccnt,bcname); bbccnt++; }
}
}
}
//!!
for (int k = 1; k <= mesh.GetNFD(); k++)

View File

@ -19,6 +19,21 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
splines.Append(spline);
bcnames.Append(bcname);
}
string* SplineSurface :: GetBCNameOf (Point<3> p1, Point<3> p2) const
{
(*testout) << "segment: " << p1 << ", " << p2 << endl;
for(int i=0; i<splines.Size(); i++)
{
(*testout) << "spline: " << splines[i]->GetPoint(0) << ", " << splines[i]->GetPoint(1) << endl;
if (((splines[i]->GetPoint(0)-p1).Length()<1e-12 && (splines[i]->GetPoint(1)-p2).Length() < 1e-12) || ((splines[i]->GetPoint(0)-p2).Length() < 1e-12 && (splines[i]->GetPoint(1)-p1).Length() < 1e-12))
{
(*testout) << "return bcname: " << *bcnames[i] << endl;
return bcnames[i];
}
}
return new string("default");
}
double SplineSurface :: CalcFunctionValue (const Point<3> & point) const
{

View File

@ -23,6 +23,7 @@ namespace netgen
int GetNP() const { return geompoints.Size(); }
const GeomPoint<3> & GetPoint(int i) const { return geompoints[i]; }
string* GetBCName(int i) const { return bcnames[i]; }
string* GetBCNameOf(Point<3> p1, Point<3> p2) const;
DLL_HEADER void AppendPoint(const Point<3> & p, const double reffac = 1., const bool hpref=false);
void AppendSegment(SplineSeg<3>* spline, string* bcname);

View File

@ -13,7 +13,10 @@ NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (int nr) const
template <>
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const
{
return (*mesh)[SegmentIndex(nr)].si;
if(mesh->GetDimension()==3)
return (*mesh)[SegmentIndex(nr)].cd2i;
else
return (*mesh)[SegmentIndex(nr)].si;
}
template <>
@ -63,7 +66,10 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
Ng_Element ret;
ret.type = NG_ELEMENT_TYPE(el.GetType());
ret.index = el.si;
if(mesh->GetDimension()==2)
ret.index = el.si;
else
ret.index = el.edgenr;
ret.points.num = el.GetNP();
ret.points.ptr = (int*)&(el[0]);

View File

@ -5773,6 +5773,7 @@ namespace netgen
void Mesh :: SetCD2Name ( int cd2nr, const string & abcname )
{
(*testout) << "setCD2Name on edge " << cd2nr << " to " << abcname << endl;
if (cd2nr >= cd2names.Size())
{
int oldsize = cd2names.Size();
@ -5780,7 +5781,7 @@ namespace netgen
for(int i= oldsize; i<= cd2nr; i++)
cd2names[i] = nullptr;
}
if (cd2names[cd2nr]) delete cd2names[cd2nr];
//if (cd2names[cd2nr]) delete cd2names[cd2nr];
if (abcname != "default")
cd2names[cd2nr] = new string(abcname);
else
@ -5794,7 +5795,7 @@ namespace netgen
return defaultstring;
if (cd2nr < 0 || cd2nr >= cd2names.Size())
throw NgException ("illegal bc-number");
return defaultstring;
if (cd2names[cd2nr])
return *cd2names[cd2nr];

View File

@ -2418,6 +2418,14 @@ namespace netgen
return s;
}
string EdgeDescriptor :: default_bcname = "default";
void EdgeDescriptor :: SetBCName (string * bcn)
{
if(bcn)
bcname = bcn;
else
bcn = &default_bcname;
}

View File

@ -1005,6 +1005,9 @@ namespace netgen
{
int tlosurf;
int surfnr[2];
int bcprop;
static string default_bcname;
string* bcname = &default_bcname;
public:
EdgeDescriptor ()
: tlosurf(-1)
@ -1015,6 +1018,9 @@ namespace netgen
int TLOSurface() const { return tlosurf; }
void SetTLOSurface (int nr) { tlosurf = nr; }
int BCProperty() const { return bcprop; }
void SetBCProperty (int bc) { bcprop = bc; }
void SetBCName (string* bcn);
};