Commit 953b7fb7 authored by Michael Turner's avatar Michael Turner

add domain control to naca generator

parent 7867e9ba
......@@ -111,6 +111,11 @@ public:
return m_2d;
}
void SetNACA(std::string i)
{
m_naca = i;
}
/**
* @brief Initialises CAD and makes surface, curve and vertex maps.
*
......@@ -203,6 +208,7 @@ protected:
std::map<int, CADVertSharedPtr> m_verts;
bool m_2d;
std::string m_naca;
};
typedef boost::shared_ptr<CADSystem> CADSystemSharedPtr;
......
......@@ -32,6 +32,7 @@
// Description: cad object methods.
//
////////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
#include <NekMeshUtils/CADSystem/OCE/CADSystemOCE.h>
#include <NekMeshUtils/CADSystem/OCE/CADVertOCE.h>
......@@ -51,8 +52,9 @@ std::string CADSystemOCE::key = GetEngineFactory().RegisterCreatorFunction(
bool CADSystemOCE::LoadCAD()
{
if (m_name.find('.') != std::string::npos)
if (m_naca.size() == 0)
{
//not a naca profile behave normally
// Takes step file and makes OpenCascade shape
STEPControl_Reader reader;
reader = STEPControl_Reader();
......@@ -67,13 +69,7 @@ bool CADSystemOCE::LoadCAD()
}
else
{
//cout << m_name << " is not a step file, assuming it is a 4 digit naca code" << endl;
shape = BuildNACA(m_name);
/*STEPControl_Writer writer;
writer.Transfer(shape,STEPControl_ShellBasedSurfaceModel);
writer.Write("test.stp");
exit(-1);*/
}
// faces and verts can be extracted straight from shape
......@@ -365,6 +361,9 @@ Array<OneD, NekDouble> CADSystemOCE::GetBoundingBox()
TopoDS_Shape CADSystemOCE::BuildNACA(string naca)
{
ASSERTL0(naca.length() == 4, "not a 4 digit code");
vector<NekDouble> data;
ParseUtils::GenerateUnOrderedVector(m_naca.c_str(), data);
ASSERTL0(data.size() == 5, "not a vaild domain");
int n = boost::lexical_cast<int>(naca);
NekDouble T = (n%100) / 100.0;
......@@ -443,13 +442,25 @@ TopoDS_Shape CADSystemOCE::BuildNACA(string naca)
BRepBuilderAPI_MakeWire aeroWireBuilder(aeroEdge, TeEdge);
TopoDS_Wire aeroWire = aeroWireBuilder.Wire();
BRepBuilderAPI_MakeEdge domInlBuilder(gp_Pnt(-2000.0,-2000.0,0.0), gp_Pnt(-2000.0,2000.0,0.0));
gp_Trsf transform;
gp_Ax1 rotAx(gp_Pnt(500.0,0.0,0.0),gp_Dir(gp_Vec(0.0,0.0,-1.0)));
transform.SetRotation(rotAx, data[4]/180.0*M_PI);
TopLoc_Location mv(transform);
aeroWire.Move(mv);
BRepBuilderAPI_MakeEdge domInlBuilder(gp_Pnt(data[0]*1000.0,data[1]*1000.0,0.0),
gp_Pnt(data[0]*1000.0,data[3]*1000.0,0.0));
TopoDS_Edge inlEdge = domInlBuilder.Edge();
BRepBuilderAPI_MakeEdge domTopBuilder(gp_Pnt(-2000.0,2000.0,0.0), gp_Pnt(5000.0,2000.0,0.0));
BRepBuilderAPI_MakeEdge domTopBuilder(gp_Pnt(data[0]*1000.0,data[3]*1000.0,0.0),
gp_Pnt(data[2]*1000.0,data[3]*1000.0,0.0));
TopoDS_Edge topEdge = domTopBuilder.Edge();
BRepBuilderAPI_MakeEdge domOutBuilder(gp_Pnt(5000.0,2000.0,0.0), gp_Pnt(5000.0,-2000.0,0.0));
BRepBuilderAPI_MakeEdge domOutBuilder(gp_Pnt(data[2]*1000.0,data[3]*1000.0,0.0),
gp_Pnt(data[2]*1000.0,data[1]*1000.0,0.0));
TopoDS_Edge outEdge = domOutBuilder.Edge();
BRepBuilderAPI_MakeEdge domBotBuilder(gp_Pnt(5000.0,-2000.0,0.0), gp_Pnt(-2000.0,-2000.0,0.0));
BRepBuilderAPI_MakeEdge domBotBuilder(gp_Pnt(data[2]*1000.0,data[1]*1000.0,0.0),
gp_Pnt(data[0]*1000.0,data[1]*1000.0,0.0));
TopoDS_Edge botEdge = domBotBuilder.Edge();
BRepBuilderAPI_MakeWire domWireBuilder(inlEdge, topEdge, outEdge, botEdge);
......
......@@ -78,5 +78,6 @@
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <STEPControl_Writer.hxx>
#include <gp_Ax1.hxx>
#endif
......@@ -53,6 +53,8 @@ ProcessLoadCAD::ProcessLoadCAD(MeshSharedPtr m) : ProcessModule(m)
ConfigOption(false, "", "Generate prisms on these surfs");
m_config["2D"] =
ConfigOption(true, "", "allow 2d loading");
m_config["NACA"] =
ConfigOption(false, "", "naca domain");
}
ProcessLoadCAD::~ProcessLoadCAD()
......@@ -75,6 +77,11 @@ void ProcessLoadCAD::Process()
m_mesh->m_cad->Set2D();
}
if(m_config["NACA"].beenSet)
{
m_mesh->m_cad->SetNACA(m_config["NACA"].as<string>());
}
ASSERTL0(m_mesh->m_cad->LoadCAD(), "Failed to load CAD");
if (m_mesh->m_verbose)
......
......@@ -204,6 +204,31 @@ void InputCAD::ParseFile(string nm)
}
}
m_naca = false;
if(m_2D && m_cadfile.find('.') == std::string::npos)
{
m_naca = true;
stringstream ss;
it = parameters.find("Xmin");
ASSERTL0(it != parameters.end(), "no xmin defined");
ss << it->second << ",";
it = parameters.find("Ymin");
ASSERTL0(it != parameters.end(), "no ymin defined");
ss << it->second << ",";
it = parameters.find("Xmax");
ASSERTL0(it != parameters.end(), "no xmax defined");
ss << it->second << ",";
it = parameters.find("Ymax");
ASSERTL0(it != parameters.end(), "no zmax defined");
ss << it->second << ",";
it = parameters.find("AOA");
ASSERTL0(it != parameters.end(), "no aoa defined");
ss << it->second;
m_nacadomain = ss.str();
}
set<string>::iterator sit;
sit = boolparameters.find("SurfOpti");
m_surfopti = sit != boolparameters.end();
......@@ -245,6 +270,10 @@ void InputCAD::Process()
{
mods.back()->RegisterConfig("2D","");
}
if(m_naca)
{
mods.back()->RegisterConfig("NACA",m_nacadomain);
}
////**** Octree ****////
mods.push_back(GetModuleFactory().CreateInstance(
......
......@@ -62,8 +62,10 @@ public:
private:
std::string m_minDelta, m_maxDelta, m_eps, m_cadfile, m_order,
m_blsurfs, m_blthick, m_blprog, m_bllayers, m_refinement;
bool m_makeBL, m_surfopti, m_varopti, m_refine, m_woct, m_2D, m_splitBL;
m_blsurfs, m_blthick, m_blprog, m_bllayers, m_refinement,
m_nacadomain;
bool m_makeBL, m_surfopti, m_varopti, m_refine, m_woct, m_2D, m_splitBL,
m_naca;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment