python cd2 functionality, mesh scaling

This commit is contained in:
Christopher Lackner 2016-10-28 16:49:50 +02:00
parent 7a6de7b1dc
commit 767b819e5d
5 changed files with 22 additions and 4 deletions

View File

@ -1410,7 +1410,6 @@ namespace netgen
seg.surfnr2 = refedges.Get(k).surfnr2;
seg.seginfo = 0;
if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1;
*testout << "add segment at 3" << endl;
mesh.AddSegment (seg);
//(*testout) << "add seg " << mesh[seg.p1] << "-" << mesh[seg.p2] << endl;
//(*testout) << "refedge " << k << " surf1 " << seg.surfnr1 << " surf2 " << seg.surfnr2 << " inv " << refedgesinv.Get(k) << endl;
@ -1579,7 +1578,6 @@ namespace netgen
seg.surfnr2 = refedges.Get(k).surfnr2;
seg.seginfo = 0;
if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1;
*testout << "add segment at 1" << endl;
mesh.AddSegment (seg);
// (*testout) << "add seg " << seg[0] << "-" << seg[1] << endl;
}
@ -1711,7 +1709,6 @@ namespace netgen
seg.surfnr2 = refedges.Get(k).surfnr2;
seg.seginfo = 0;
if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1;
*testout << "add segment at 2" << endl;
mesh.AddSegment (seg);
// (*testout) << "copy seg " << seg[0] << "-" << seg[1] << endl;
#ifdef DEVELOP

View File

@ -1120,7 +1120,7 @@ namespace netgen
{
Segment & seg = LineSegment(i);
if ( seg.cd2i <= n )
seg.SetBCName (cd2names[seg.cd2i-1]);
seg.SetBCName (cd2names[seg.edgenr-1]);
else
seg.SetBCName(0);
}
@ -1407,7 +1407,9 @@ namespace netgen
if(seg.surfnr2 >= 0) seg.surfnr2 = seg.surfnr2 + max_surfnr;
seg[0] = seg[0] +oldnp;
seg[1] = seg[1] +oldnp;
*testout << "old edgenr: " << seg.edgenr << endl;
seg.edgenr = seg.edgenr + oldne;
*testout << "new edgenr: " << seg.edgenr << endl;
seg.epgeominfo[1].edgenr = seg.epgeominfo[1].edgenr + oldne;
AddSegment (seg);

View File

@ -595,6 +595,7 @@ namespace netgen
DLL_HEADER void SetCD2Name (int cd2nr, const string & abcname);
const string & GetCD2Name (int cd2nr ) const;
size_t GetNCD2Names() const { return cd2names.Size(); }
string * GetBCNamePtr (int bcnr) const
{ return bcnr < bcnames.Size() ? bcnames[bcnr] : nullptr; }

View File

@ -251,6 +251,8 @@ namespace netgen
singular = 0;
}
void Scale(double factor) { *testout << "before: " << x[0] << endl; x[0] *= factor; x[1] *= factor; x[2] *= factor; *testout << "after: " << x[0] << endl;}
int GetLayer() const { return layer; }
POINTTYPE Type() const { return type; }

View File

@ -216,6 +216,7 @@ DLL_HEADER void ExportNetgenMeshing()
tmp->surfnr1 = bp::extract<int>(surfaces[0]);
tmp->surfnr2 = bp::extract<int>(surfaces[1]);
}
tmp->edgenr = index;
return tmp;
}),
bp::default_call_policies(),
@ -242,6 +243,10 @@ DLL_HEADER void ExportNetgenMeshing()
li.append (self.surfnr2);
return li;
}))
.add_property("index", FunctionPointer([](const Segment &self) -> size_t
{
return self.edgenr;
}))
;
@ -465,6 +470,11 @@ DLL_HEADER void ExportNetgenMeshing()
.def ("SetMaterial", &Mesh::SetMaterial)
.def ("GetMaterial", FunctionPointer([](Mesh & self, int domnr)
{ return string(self.GetMaterial(domnr)); }))
.def ("SetCD2Name", &Mesh::SetCD2Name)
.def ("GetCD2Name", FunctionPointer([](Mesh & self, int nr) -> string
{ return self.GetCD2Name(nr); }))
.def ("GetNCD2Names", &Mesh::GetNCD2Names)
.def ("GenerateVolumeMesh", FunctionPointer
([](Mesh & self)
@ -564,6 +574,12 @@ DLL_HEADER void ExportNetgenMeshing()
GenerateBoundaryLayer (self, blp);
}
))
.def ("Scale", FunctionPointer([](Mesh & self, double factor)
{
for(auto i = 0; i<self.GetNP();i++)
self.Point(i).Scale(factor);
}))
;