mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
* Changes to the Boundary Layer generation system
* More user feedback when saving and exporting mesh files to disk
This commit is contained in:
parent
6f39164242
commit
b2e8610f90
@ -141,10 +141,15 @@ namespace netgen
|
|||||||
Currently, the layer height is calculated using:
|
Currently, the layer height is calculated using:
|
||||||
height = h_first_layer * (growth_factor^(num_layers - 1))
|
height = h_first_layer * (growth_factor^(num_layers - 1))
|
||||||
*/
|
*/
|
||||||
void GenerateBoundaryLayer (Mesh & mesh)
|
void GenerateBoundaryLayer (Mesh & mesh, MeshingParameters & mp)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
// Angle between a surface element and a growth-vector below which
|
||||||
|
// a prism is project onto that surface as a quad
|
||||||
|
// (in degrees)
|
||||||
|
double angleThreshold = 15.0;
|
||||||
|
|
||||||
cout << "Generate Prismatic Boundary Layers (Experimental)...." << endl;
|
cout << "Generate Prismatic Boundary Layers (Experimental)...." << endl;
|
||||||
|
|
||||||
// Use an array to support creation of boundary
|
// Use an array to support creation of boundary
|
||||||
@ -168,6 +173,12 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "Number of surfaces entered = " << surfid.Size() << endl;
|
cout << "Number of surfaces entered = " << surfid.Size() << endl;
|
||||||
|
cout << "Selected surfaces are:" << endl;
|
||||||
|
|
||||||
|
for(i = 1; i <= surfid.Size(); i++)
|
||||||
|
{
|
||||||
|
cout << "Surface " << i << ": " << surfid.Elem(i) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
cout << endl << "Enter number of prism layers: ";
|
cout << endl << "Enter number of prism layers: ";
|
||||||
cin >> prismlayers;
|
cin >> prismlayers;
|
||||||
@ -188,8 +199,18 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
cout << "Generating layer: " << layer << endl;
|
cout << "Generating layer: " << layer << endl;
|
||||||
|
|
||||||
//double layerht = hfirst + growthfactor*(layer - 1)*hfirst;
|
double layerht = hfirst;
|
||||||
double layerht = hfirst*pow(growthfactor,(double)(layer-1));
|
|
||||||
|
if(growthfactor == 1)
|
||||||
|
{
|
||||||
|
layerht = layer * hfirst;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
layerht = hfirst*(pow(growthfactor,(layer+1)) - 1)/(growthfactor - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Layer Height = " << layerht << endl;
|
||||||
|
|
||||||
// Need to store the old number of points and
|
// Need to store the old number of points and
|
||||||
// surface elements because there are new points and
|
// surface elements because there are new points and
|
||||||
@ -201,6 +222,9 @@ namespace netgen
|
|||||||
// consistency
|
// consistency
|
||||||
int nseg = mesh.GetNSeg();
|
int nseg = mesh.GetNSeg();
|
||||||
|
|
||||||
|
// Update the mesh topology structures
|
||||||
|
mesh.UpdateTopology();
|
||||||
|
|
||||||
const MeshTopology& meshtopo = mesh.GetTopology();
|
const MeshTopology& meshtopo = mesh.GetTopology();
|
||||||
|
|
||||||
// Indicate which points need to be remapped
|
// Indicate which points need to be remapped
|
||||||
@ -213,9 +237,6 @@ namespace netgen
|
|||||||
// the effective surface normal at a given point
|
// the effective surface normal at a given point
|
||||||
Array<Vec3d> growthvectors(np);
|
Array<Vec3d> growthvectors(np);
|
||||||
|
|
||||||
// Update the mesh topology structures
|
|
||||||
mesh.UpdateTopology();
|
|
||||||
|
|
||||||
// Bit array to identify all the points belonging
|
// Bit array to identify all the points belonging
|
||||||
// to the surface of interest
|
// to the surface of interest
|
||||||
bndnodes.Clear();
|
bndnodes.Clear();
|
||||||
@ -369,8 +390,13 @@ namespace netgen
|
|||||||
mesh.LineSegment(j)[1] = mapto.Get(seg_p1);
|
mesh.LineSegment(j)[1] = mapto.Get(seg_p1);
|
||||||
mesh.LineSegment(j)[0] = mapto.Get(seg_p2);
|
mesh.LineSegment(j)[0] = mapto.Get(seg_p2);
|
||||||
|
|
||||||
if(surfangle <= 1.5707)
|
if(surfangle <= angleThreshold * 3.141592 / 180.0)
|
||||||
{
|
{
|
||||||
|
// Since the surface is lower than the threshold, change the effective
|
||||||
|
// prism growth vector to match with the surface vector, so that
|
||||||
|
// the Quad which is created lies on the original surface
|
||||||
|
growthvectors.Elem(segpair_p1) = surfelem_vect;
|
||||||
|
|
||||||
// Add a quad element to account for the prism volume
|
// Add a quad element to account for the prism volume
|
||||||
// element which is going to be added
|
// element which is going to be added
|
||||||
Element2d sel(QUAD);
|
Element2d sel(QUAD);
|
||||||
@ -521,24 +547,27 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
double sfact = 0.9;
|
double sfact = 0.9;
|
||||||
Element volel = mesh.VolumeElement(vertelems.Elem(j));
|
Element volel = mesh.VolumeElement(vertelems.Elem(j));
|
||||||
if((volel.GetType() == TET) || (volel.GetType() == TET10))
|
if(((volel.GetType() == TET) || (volel.GetType() == TET10)) && (!volel.IsDeleted()))
|
||||||
{
|
{
|
||||||
while((volel.Volume(mesh.Points()) <= 0.0) && (sfact >= 0.0))
|
//while((volel.Volume(mesh.Points()) <= 0.0) && (sfact >= 0.0))
|
||||||
{
|
//{
|
||||||
mesh.Point(i).SetPoint(pointtomove + (sfact * layerht * growthvectors.Elem(i)));
|
// mesh.Point(i).SetPoint(pointtomove + (sfact * layerht * growthvectors.Elem(i)));
|
||||||
mesh.ImproveMesh();
|
// mesh.ImproveMesh();
|
||||||
|
|
||||||
// Try to move the point back by one step but
|
// // Try to move the point back by one step but
|
||||||
// if the volume drops to below zero, double back
|
// // if the volume drops to below zero, double back
|
||||||
mesh.Point(i).SetPoint(pointtomove + ((sfact + 0.1) * layerht * growthvectors.Elem(i)));
|
// mesh.Point(i).SetPoint(pointtomove + ((sfact + 0.1) * layerht * growthvectors.Elem(i)));
|
||||||
if(volel.Volume(mesh.Points()) <= 0.0)
|
// if(volel.Volume(mesh.Points()) <= 0.0)
|
||||||
{
|
// {
|
||||||
mesh.Point(i).SetPoint(pointtomove + (sfact * layerht * growthvectors.Elem(i)));
|
// mesh.Point(i).SetPoint(pointtomove + (sfact * layerht * growthvectors.Elem(i)));
|
||||||
}
|
// }
|
||||||
sfact -= 0.1;
|
// sfact -= 0.1;
|
||||||
}
|
//}
|
||||||
|
volel.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mesh.Compress();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ extern void InsertVirtualBoundaryLayer (Mesh & mesh);
|
|||||||
|
|
||||||
/// Create a typical prismatic boundary layer on the given
|
/// Create a typical prismatic boundary layer on the given
|
||||||
/// surfaces
|
/// surfaces
|
||||||
extern void GenerateBoundaryLayer (Mesh & mesh);
|
extern void GenerateBoundaryLayer (Mesh & mesh, MeshingParameters & mp);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -399,7 +399,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
const string filename (argv[1]);
|
const string filename (argv[1]);
|
||||||
PrintMessage (1, "Save mesh to file ", filename);
|
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
||||||
|
|
||||||
ofstream outfile(filename.c_str());
|
ofstream outfile(filename.c_str());
|
||||||
mesh -> Save (outfile);
|
mesh -> Save (outfile);
|
||||||
@ -408,6 +408,7 @@ namespace netgen
|
|||||||
|
|
||||||
if (geometry && geometry->GetNSurf()) geometry->SaveSurfaces(outfile);
|
if (geometry && geometry->GetNSurf()) geometry->SaveSurfaces(outfile);
|
||||||
|
|
||||||
|
PrintMessage (1, "Save mesh to file .... DONE!");
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +466,7 @@ namespace netgen
|
|||||||
|
|
||||||
string filename (argv[1]);
|
string filename (argv[1]);
|
||||||
string filetype (argv[2]);
|
string filetype (argv[2]);
|
||||||
|
PrintMessage (1, "Export mesh to file ", filename, ".... Please Wait!");
|
||||||
|
|
||||||
if (WriteUserFormat (filetype, *mesh, *geometry, filename))
|
if (WriteUserFormat (filetype, *mesh, *geometry, filename))
|
||||||
{
|
{
|
||||||
@ -474,6 +476,7 @@ namespace netgen
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintMessage (1, "Export mesh to file .... DONE!");
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1868,7 +1871,7 @@ namespace netgen
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateBoundaryLayer (*mesh);
|
GenerateBoundaryLayer (*mesh, mparam);
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user