added: support for rational default geometries
This commit is contained in:
committed by
Knut Morten Okstad
parent
3001e5fdf6
commit
8e3dbc473f
@@ -532,7 +532,13 @@ ASMbase* SIM1D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
{
|
||||
std::string g2("100 1 0 0\n");
|
||||
g2.append(1,'0'+nsd);
|
||||
g2.append(" 0\n2 2\n0 0 1 1\n");
|
||||
|
||||
bool rational=false;
|
||||
utl::getAttribute(geo,"rational",rational);
|
||||
if (rational)
|
||||
IFEM::cout << "\t Rational basis\n";
|
||||
g2.append(rational?" 1":" 0");
|
||||
g2.append("\n2 2\n0 0 1 1\n");
|
||||
|
||||
unsigned char d;
|
||||
std::string XYZ;
|
||||
@@ -547,6 +553,8 @@ ASMbase* SIM1D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
for (d = 1; d < nsd; d++)
|
||||
g2.append(" 0.0");
|
||||
}
|
||||
if (rational)
|
||||
g2.append(" 1.0");
|
||||
g2.append("\n");
|
||||
if (utl::getAttribute(geo,"X1",XYZ))
|
||||
{
|
||||
@@ -562,6 +570,8 @@ ASMbase* SIM1D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
for (d = 1; d < nsd; d++)
|
||||
g2.append(" 0.0");
|
||||
}
|
||||
if (rational)
|
||||
g2.append(" 1.0");
|
||||
g2.append("\n");
|
||||
|
||||
std::istringstream unitLine(g2);
|
||||
|
||||
@@ -770,7 +770,12 @@ ASMbase* SIM2D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
{
|
||||
std::string g2("200 1 0 0\n");
|
||||
g2.append(nsd > 2 ? "3" : "2");
|
||||
g2.append(" 0\n2 2\n0 0 1 1\n2 2\n0 0 1 1");
|
||||
bool rational=false;
|
||||
utl::getAttribute(geo,"rational",rational);
|
||||
if (rational)
|
||||
IFEM::cout << "\t Rational basis\n";
|
||||
g2.append(rational?" 1":" 0");
|
||||
g2.append("\n2 2\n0 0 1 1\n2 2\n0 0 1 1");
|
||||
|
||||
Vec3 X0;
|
||||
std::string corner;
|
||||
@@ -794,18 +799,22 @@ ASMbase* SIM2D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
std::stringstream str;
|
||||
str <<"\n"<< X0.x <<" "<< X0.y;
|
||||
if (nsd > 2) str <<" 0.0";
|
||||
if (rational) str << " 1.0";
|
||||
g2.append(str.str());
|
||||
str.str("");
|
||||
str <<"\n"<< X0.x+Lx <<" "<< X0.y;
|
||||
if (nsd > 2) str <<" 0.0";
|
||||
if (rational) str << " 1.0";
|
||||
g2.append(str.str());
|
||||
str.str("");
|
||||
str <<"\n"<< X0.x <<" "<< X0.y+Ly;
|
||||
if (nsd > 2) str <<" 0.0";
|
||||
if (rational) str << " 1.0";
|
||||
g2.append(str.str());
|
||||
str.str("");
|
||||
str <<"\n"<< X0.x+Lx <<" "<< X0.y+Ly;
|
||||
if (nsd > 2) str <<" 0.0";
|
||||
if (rational) str << " 1.0";
|
||||
g2.append(str.str());
|
||||
g2.append("\n");
|
||||
|
||||
|
||||
@@ -774,26 +774,38 @@ bool SIM3D::readNodes (std::istream& isn, int pchInd, int basis, bool oneBased)
|
||||
|
||||
ASMbase* SIM3D::createDefaultGeometry (const TiXmlElement* geo) const
|
||||
{
|
||||
std::string g2("700 1 0 0\n3 0\n"
|
||||
"2 2\n0 0 1 1\n"
|
||||
"2 2\n0 0 1 1\n"
|
||||
"2 2\n0 0 1 1\n"
|
||||
"0.0 0.0 0.0\n"
|
||||
"1.0 0.0 0.0\n"
|
||||
"0.0 1.0 0.0\n"
|
||||
"1.0 1.0 0.0\n"
|
||||
"0.0 0.0 1.0\n"
|
||||
"1.0 0.0 1.0\n"
|
||||
"0.0 1.0 1.0\n"
|
||||
"1.0 1.0 1.0\n");
|
||||
|
||||
std::string scale;
|
||||
if (utl::getAttribute(geo,"scale",scale) && scale != "1.0")
|
||||
{
|
||||
std::string g2("700 1 0 0\n3 ");
|
||||
bool rational=false;
|
||||
utl::getAttribute(geo,"rational",rational);
|
||||
if (rational)
|
||||
IFEM::cout << "\t Rational basis\n";
|
||||
double scale = 1.0;
|
||||
if (utl::getAttribute(geo,"scale",scale))
|
||||
IFEM::cout <<"\tscale = "<< scale << std::endl;
|
||||
size_t i = 0, j = 0, ns = scale.size();
|
||||
for (; (i = g2.find("1.0",j)) != std::string::npos; j=i+ns)
|
||||
g2.replace(i,3,scale);
|
||||
|
||||
g2.append(rational?"1\n":"0\n");
|
||||
g2.append("2 2\n0 0 1 1\n"
|
||||
"2 2\n0 0 1 1\n"
|
||||
"2 2\n0 0 1 1\n");
|
||||
|
||||
const std::array<std::array<double,3>,8> nodes =
|
||||
{{{0.0,0.0,0.0},
|
||||
{1.0,0.0,0.0},
|
||||
{0.0,1.0,0.0},
|
||||
{1.0,1.0,0.0},
|
||||
{0.0,0.0,1.0},
|
||||
{1.0,0.0,1.0},
|
||||
{0.0,1.0,1.0},
|
||||
{1.0,1.0,1.0}}};
|
||||
for (const auto& it : nodes)
|
||||
{
|
||||
std::stringstream str;
|
||||
for (const auto& it2 : it)
|
||||
str << it2*scale << " ";
|
||||
g2.append(str.str());
|
||||
if (rational)
|
||||
g2.append(" 1.0");
|
||||
g2.append("\n");
|
||||
}
|
||||
|
||||
std::istringstream unitCube(g2);
|
||||
|
||||
Reference in New Issue
Block a user