Ejemplo n.º 1
0
TEST_F(OGSIOVer4InterfaceTest, InvalidTIN_ZeroAreaTri)
{
    std::string tin_fname(BaseLib::BuildInfo::tests_tmp_path+"Surface.tin");
    std::ofstream tin_out (tin_fname);
    tin_out << "0 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 0.0\n";
    tin_out.close();

    // read geometry
    GeoLib::GEOObjects geometries;
    std::vector<std::string> errors;
    std::string geometry_name("TestGeometry");
    FileIO::Legacy::readGLIFileV4(_gli_fname, geometries, geometry_name,
                                  errors, "dummy_for_gmsh_path");

    std::vector<GeoLib::Surface*> const*
        sfcs(geometries.getSurfaceVec(geometry_name));
    ASSERT_TRUE(sfcs == nullptr);

    std::remove(tin_fname.c_str());
}
Ejemplo n.º 2
0
TEST_F(OGSIOVer4InterfaceTest, StillCorrectTINWihtAdditionalValueAtEndOfLine)
{
    std::string tin_fname(BaseLib::BuildInfo::tests_tmp_path+"Surface.tin");
    std::ofstream tin_out (tin_fname);
    tin_out << "0 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 1.0 10\n";
    tin_out << "1 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 1.0\n";
    tin_out.close();

    // read geometry
    GeoLib::GEOObjects geometries;
    std::vector<std::string> errors;
    std::string geometry_name("TestGeometry");
    FileIO::Legacy::readGLIFileV4(_gli_fname, geometries, geometry_name,
                                  errors, "dummy_for_gmsh_path");

    std::vector<GeoLib::Surface*> const*
        sfcs(geometries.getSurfaceVec(geometry_name));
    ASSERT_TRUE(sfcs != nullptr);
    ASSERT_EQ(1u, geometries.getSurfaceVec(geometry_name)->size());
    ASSERT_EQ(2u, (*geometries.getSurfaceVec(geometry_name))[0]->getNumberOfTriangles());

    std::remove(tin_fname.c_str());
}
Ejemplo n.º 3
0
void XmlCndInterface::readConditions( const QDomNode &listRoot,
                                   std::vector<FEMCondition*> &conditions,
                                   FEMCondition::CondType type)
{
	QDomElement cond = listRoot.firstChildElement();
	while (!cond.isNull())
	{
		std::string geometry_name ( cond.attribute("geometry").toStdString() );
		if (this->_project->getGEOObjects()->exists(geometry_name) >= 0 ||
			this->_project->meshExists(geometry_name))
		{

			FEMCondition* c ( new FEMCondition(geometry_name, type) );

			QDomNodeList condProperties = cond.childNodes();
			for (int i = 0; i < condProperties.count(); i++)
			{
				const QDomNode prop_node (condProperties.at(i));
				if (condProperties.at(i).nodeName().compare("Process") == 0)
				{
					QDomNodeList processProps = prop_node.childNodes();
					for (int j = 0; j < processProps.count(); j++)
					{
						const QString prop_name(processProps.at(j).nodeName());
						if (prop_name.compare("Type") == 0)
							c->setProcessType(FiniteElement::convertProcessType(processProps.at(j).toElement().text().toStdString()));
						else if (prop_name.compare("Variable") == 0)
							c->setProcessPrimaryVariable(FiniteElement::convertPrimaryVariable(processProps.at(j).toElement().text().toStdString()));
					}
				}
				else if (prop_node.nodeName().compare("Geometry") == 0)
				{
					QDomNodeList geoProps = prop_node.childNodes();
					for (int j = 0; j < geoProps.count(); j++)
					{
						const QString prop_name(geoProps.at(j).nodeName());
						if (prop_name.compare("Type") == 0)
							c->setGeoType(GeoLib::convertGeoType(geoProps.at(j).toElement().text().toStdString()));
						else if (prop_name.compare("Name") == 0)
							c->setGeoName(geoProps.at(j).toElement().text().toStdString());
					}
				}
				else if (prop_node.nodeName().compare("Distribution") == 0)
				{
					QDomNodeList distProps = prop_node.childNodes();
					for (int j = 0; j < distProps.count(); j++)
					{
						const QString prop_name(distProps.at(j).nodeName());
						if (prop_name.compare("Type") == 0)
							c->setProcessDistributionType(FiniteElement::convertDisType(distProps.at(j).toElement().text().toStdString()));
						else if (prop_name.compare("Value") == 0)
						{
							std::vector<size_t> disNodes;
							std::vector<double> disValues;
							if (c->getProcessDistributionType()==FiniteElement::CONSTANT ||
								c->getProcessDistributionType()==FiniteElement::CONSTANT_NEUMANN)
								disValues.push_back( strtod(distProps.at(j).toElement().text().toStdString().c_str(), 0) );
							else if (c->getProcessDistributionType()==FiniteElement::LINEAR ||
								     c->getProcessDistributionType()==FiniteElement::LINEAR_NEUMANN ||
									 c->getProcessDistributionType()==FiniteElement::DIRECT)
							{
								QString text = distProps.at(j).toElement().text();
								QStringList list = text.split(QRegExp("\\t"));
								size_t count(0);
								for (QStringList::iterator it=list.begin(); it!=list.end(); ++it)
								{
									std::string val (it->trimmed().toStdString());
									if (!val.empty())
									{
										if (count%2==0)
											disNodes.push_back(atoi(val.c_str()));
										else
											disValues.push_back(strtod(val.c_str(), 0));
										count++;
									}
								}
							}
							else
								std::cout << "Error in XmlCndInterface::readConditions() - Distribution type not supported." << std::endl;
							c->setDisValues(disNodes, disValues);
						}
					}
				}
			}
			conditions.push_back(c);
		}
		else
		{
			std::cout << "Error loading FEM Conditions: No geometry \"" << geometry_name << "\" found." << std::endl;
		}
		cond = cond.nextSiblingElement();
	}
}