diff --git a/Applications/CMakeLists.txt b/Applications/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a8fb8a985d1db003e0136769a0b09a4924b070b2 --- /dev/null +++ b/Applications/CMakeLists.txt @@ -0,0 +1,10 @@ +# Source files +SET ( LIB_SOURCES ProjectData.cpp ) + +# Library +ADD_LIBRARY (ApplicationsLib STATIC ${LIB_SOURCES}) + +TARGET_LINK_LIBRARIES( ApplicationsLib + GeoLib + ProcessLib + ) diff --git a/Applications/ProjectData.cpp b/Applications/ProjectData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4e8649406eedc28aa78cab62f8b50342e4cfe478 --- /dev/null +++ b/Applications/ProjectData.cpp @@ -0,0 +1,207 @@ +/** + * \author Karsten Rink + * \date 2010-08-25 + * \brief Implementation of the project data class. + * + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "ProjectData.h" + +#include <algorithm> + +// ThirdParty/logog +#include "logog/include/logog.hpp" + +#include "BaseLib/FileTools.h" + +#include "MeshLib/Mesh.h" +#include "ProcessLib/Process.h" + +// FileIO +#include "FileIO/XmlIO/Boost/BoostXmlGmlInterface.h" +#include "FileIO/readMeshFromFile.h" + +namespace detail +{ +void readGeometry(std::string const& fname, GeoLib::GEOObjects & geo_objects) +{ + DBUG("Reading geometry file \'%s\'.", fname.c_str()); + FileIO::BoostXmlGmlInterface gml_reader(geo_objects); + gml_reader.readFile(fname); +} + +} + +ProjectData::ProjectData(ConfigTree const& project_config, + std::string const& path) +{ + // geometry + std::string const geometry_file = BaseLib::copyPathToFileName( + project_config.get<std::string>("geometry"), path + ); + detail::readGeometry(geometry_file, *_geoObjects); + + // mesh + std::string const mesh_file = BaseLib::copyPathToFileName( + project_config.get<std::string>("mesh"), path + ); + + MeshLib::Mesh* const mesh = FileIO::readMeshFromFile(mesh_file); + if (!mesh) + ERR("Could not read mesh from \'%s\' file. No mesh added.", + mesh_file.c_str()); + _mesh_vec.push_back(mesh); + + // process variables + parseProcessVariables(project_config.get_child("process_variables")); + + // processes + parseProcesses(project_config.get_child("processes")); +} + +ProjectData::~ProjectData() +{ + delete _geoObjects; + + for(ProcessLib::Process* p : _processes) + delete p; + + for (MeshLib::Mesh* m : _mesh_vec) + delete m; +} + +void ProjectData::addMesh(MeshLib::Mesh* mesh) +{ + std::string name = mesh->getName(); + isMeshNameUniqueAndProvideUniqueName(name); + mesh->setName(name); + _mesh_vec.push_back(mesh); +} + +std::vector<MeshLib::Mesh*>::const_iterator ProjectData::findMeshByName( + std::string const& name) const +{ + return findMeshByName(name); +} + +std::vector<MeshLib::Mesh*>::iterator ProjectData::findMeshByName( + std::string const& name) +{ + return std::find_if(_mesh_vec.begin(), _mesh_vec.end(), + [&name](MeshLib::Mesh* mesh) + { + return mesh && (name == mesh->getName()); + }); + +} + +const MeshLib::Mesh* ProjectData::getMesh(const std::string &name) const +{ + std::vector<MeshLib::Mesh*>::const_iterator it = findMeshByName(name); + return (it == _mesh_vec.end() ? nullptr : *it); +} + +bool ProjectData::removeMesh(const std::string &name) +{ + bool mesh_found = false; + std::vector<MeshLib::Mesh*>::iterator it = findMeshByName(name); + while (it != _mesh_vec.end()) + { + delete *it; + *it = nullptr; + it = findMeshByName(name); + mesh_found = true; + } + + _mesh_vec.erase(std::remove(_mesh_vec.begin(), _mesh_vec.end(), nullptr), + _mesh_vec.end()); + return mesh_found; +} + +bool ProjectData::meshExists(const std::string &name) const +{ + return findMeshByName(name) != _mesh_vec.end(); +} + +bool ProjectData::isMeshNameUniqueAndProvideUniqueName(std::string &name) const +{ + int count(0); + bool isUnique(false); + std::string cpName; + + while (!isUnique) + { + isUnique = true; + cpName = name; + + count++; + // If the original name already exists we start to add numbers to name for + // as long as it takes to make the name unique. + if (count > 1) + cpName = cpName + "-" + std::to_string(count); + + for (std::vector<MeshLib::Mesh*>::const_iterator it = _mesh_vec.begin(); + it != _mesh_vec.end(); ++it) + if ( cpName.compare((*it)->getName()) == 0 ) + isUnique = false; + } + + // At this point cpName is a unique name and isUnique is true. + // If cpName is not the original name, "name" is changed and isUnique is set to false, + // indicating that a vector with the original name already exists. + if (count > 1) + { + isUnique = false; + name = cpName; + } + return isUnique; +} + +void ProjectData::parseProcessVariables( + ConfigTree const& process_variables_config) +{ + DBUG("Parse process variables:") + if (_geoObjects == nullptr) { + ERR("Geometric objects are required to define process variables."); + ERR("No geometric objects present."); + return; + } + + // TODO at the moment we have only one mesh, later there + // can be several meshes. Then we have to check for correct mesh here and + // assign the referenced mesh below. + if (_mesh_vec.empty() || _mesh_vec[0] == nullptr) { + ERR("A mesh is required to define process variables."); + return; + } + + for (auto it : process_variables_config) { + ConfigTree const& var_config = it.second; + // TODO Extend to referenced meshes. + _process_variables.emplace_back(var_config,*_mesh_vec[0],*_geoObjects); + } +} + +void ProjectData::parseProcesses(ConfigTree const& processes_config) +{ + DBUG("Reading processes:\n"); + for (auto pc_it : processes_config) { + ConfigTree const& process_config = pc_it.second; + if (process_config.get<std::string>("type") == "GROUNDWATER_FLOW") { + // The existence check of the in the configuration referenced + // process variables is checked in the physical process. + // TODO at the moment we have only one mesh, later there can be + // several meshes. Then we have to assign the referenced mesh + // here. + _processes.push_back(new ProcessLib::GroundwaterFlowProcess( + *_mesh_vec[0], _process_variables, process_config) + ); + } + } +} diff --git a/Applications/ProjectData.h b/Applications/ProjectData.h new file mode 100644 index 0000000000000000000000000000000000000000..2f95070d3cc62c6b91b4a1e33377fb4cf57ae73b --- /dev/null +++ b/Applications/ProjectData.h @@ -0,0 +1,118 @@ +/** + * \author Karsten Rink + * \date 2010-08-25 + * + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROJECTDATA_H_ +#define PROJECTDATA_H_ + +#include <boost/property_tree/ptree.hpp> + +#ifdef OGS_BUILD_GUI +#include "Gui/DataView/GEOModels.h" +#else +#include "GeoLib/GEOObjects.h" +#endif + +#include "ProcessLib/ProcessVariable.h" +namespace MeshLib { + class Mesh; +} + +namespace ProcessLib { + class Process; +} + +/** + * The ProjectData Object contains all the data needed for a certain project, i.e. all + * geometric data (stored in a GEOObjects-object), all the meshes, processes, + * and process variables. + */ +class ProjectData +{ +using ConfigTree = boost::property_tree::ptree; +public: + /// The empty constructor used in the gui, for example, when the project's + /// configuration is not loaded yet. + ProjectData() = default; + + /// Constructs project data by parsing provided configuration. + /// The additional path is used to find files referenced in the + /// configuration. + ProjectData(ConfigTree const& config_tree, std::string const& path); + + virtual ~ProjectData(); + + /// Returns the GEOObjects containing all points, polylines and surfaces. + GeoLib::GEOObjects* getGEOObjects() + { + return _geoObjects; + } + + /// Adds a new mesh under a (possibly new) unique name. + /// \attention This might change the given mesh's name. + void addMesh(MeshLib::Mesh* mesh); + + /// Returns the mesh with the given name or a \c nullptr if the mesh was not + /// found. + const MeshLib::Mesh* getMesh(const std::string &name) const; + + /// Returns all the meshes with their respective names + /// \attention This method should be used only by methods garanteeing + /// read-only access to the meshes. + /// \todo This method breaks encapsulation. + const std::vector<MeshLib::Mesh*>& getMeshObjects() const + { + return _mesh_vec; + } + + /// Deletes all meshes with the given name and removes them from the list of + /// saved meshes. If any mesh was found for removal, true is returned and + /// false otherwise. + bool removeMesh(const std::string &name); + +private: + /// Checks if a mesh with the same name exists and provides a unique name in + /// case of already existing mesh. Returns true if the mesh name is unique. + /// Returns false and changes the provided name to a unique name otherwise. + bool isMeshNameUniqueAndProvideUniqueName(std::string &name) const; + + /// Returns true if a mesh with the same name exists and false otherwise. + bool meshExists(const std::string &name) const; + + + /// Returns an iterator to the first found mesh with the given name. + std::vector<MeshLib::Mesh*>::const_iterator findMeshByName( + std::string const& name) const; + std::vector<MeshLib::Mesh*>::iterator findMeshByName( + std::string const& name); + + /// Parses the process variables configuration and creates new variables for + /// each variable entry passing the corresponding subtree to the process + /// variable constructor. + void parseProcessVariables(ConfigTree const& process_variables_config); + + /// Parses the processes configuration and creates new processes for each + /// process entry passing the corresponding subtree to the process + /// constructor. + void parseProcesses(ConfigTree const& process_config); + +private: +#ifdef OGS_BUILD_GUI + GEOModels *_geoObjects = new GEOModels(); +#else + GeoLib::GEOObjects *_geoObjects = new GeoLib::GEOObjects(); +#endif + std::vector<MeshLib::Mesh*> _mesh_vec; + std::vector<ProcessLib::Process*> _processes; + std::vector<ProcessLib::ProcessVariable> _process_variables; +}; + +#endif //PROJECTDATA_H_ diff --git a/CMakeLists.txt b/CMakeLists.txt index 49ec91a58e48b86c6c6d3fe46219a3eaa874a0eb..7dc08995b6830babe9b3293085a17edf1b111464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,7 @@ IF(OGS_BUILD_GUI) ADD_SUBDIRECTORY(Gui) ENDIF() # OGS_BUILD_GUI +ADD_SUBDIRECTORY( Applications ) ADD_SUBDIRECTORY( AssemblerLib ) ADD_SUBDIRECTORY( BaseLib ) # TODO This is a hack but we have to make sure that Boost is built first @@ -147,9 +148,7 @@ ADD_SUBDIRECTORY( MathLib ) ADD_SUBDIRECTORY( MeshLib ) ADD_SUBDIRECTORY( MeshGeoToolsLib ) ADD_SUBDIRECTORY( NumLib ) -IF( OGS_BUILD_CLI ) - ADD_SUBDIRECTORY( OGS ) -ENDIF() # OGS_BUILD_CLI +ADD_SUBDIRECTORY( ProcessLib ) IF( OGS_BUILD_TESTS AND NOT IS_SUBPROJECT ) IF(CMAKE_VERSION VERSION_LESS 2.8.11) MESSAGE(FATAL_ERROR "CMAKE 2.8.11 or higher is required to build the tests!") diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index 5af74515a8d510124c69176f4bc56fa98a665d03..8257ba0d0c6d8c4b56e4ca28d1393cf1318e3fe0 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -746,7 +746,8 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = ${CMAKE_SOURCE_DIR}/AssemblerLib \ +INPUT = ${CMAKE_SOURCE_DIR}/Applications \ + ${CMAKE_SOURCE_DIR}/AssemblerLib \ ${CMAKE_SOURCE_DIR}/BaseLib \ ${CMAKE_SOURCE_DIR}/Documentation \ ${CMAKE_SOURCE_DIR}/FileIO \ @@ -755,7 +756,7 @@ INPUT = ${CMAKE_SOURCE_DIR}/AssemblerLib \ ${CMAKE_SOURCE_DIR}/MathLib \ ${CMAKE_SOURCE_DIR}/MeshLib \ ${CMAKE_SOURCE_DIR}/NumLib \ - ${CMAKE_SOURCE_DIR}/OGS \ + ${CMAKE_SOURCE_DIR}/ProcessLib \ ${CMAKE_SOURCE_DIR}/README.md \ ${CMAKE_SOURCE_DIR}/SimpleTests \ ${CMAKE_SOURCE_DIR}/Utils diff --git a/FileIO/CMakeLists.txt b/FileIO/CMakeLists.txt index 00b4bac14000e6b5eea9aab2eb465f7eda856535..1c09aec5d5e711fa03bf26654af1cf10510827ec 100644 --- a/FileIO/CMakeLists.txt +++ b/FileIO/CMakeLists.txt @@ -41,7 +41,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../GeoLib ${CMAKE_CURRENT_SOURCE_DIR}/../MathLib ${CMAKE_CURRENT_SOURCE_DIR}/../MeshLib - ${CMAKE_CURRENT_SOURCE_DIR}/../OGS ${CMAKE_CURRENT_BINARY_DIR}/../BaseLib ) diff --git a/FileIO/ImportFileTypes.h b/FileIO/ImportFileTypes.h index 5998c60ccbbd1629bc65beb07f0094bef456a3c2..4a2a315c1b2381a673a53a56a94886163ec87e6e 100644 --- a/FileIO/ImportFileTypes.h +++ b/FileIO/ImportFileTypes.h @@ -70,7 +70,7 @@ public: else if (t==ImportFileType::NETCDF) return "NetCDF files (*.nc)"; else if (t==ImportFileType::OGS) - return "OpenGeosys files (*.gsp *.gml *.vtu *.stn);;GeoSys legacy files (*.gli *.msh);;GeoSys FEM Conditions (*.cnd *.bc *.ic *.st);;All files (* *.*)"; + return "OpenGeosys files (*.gsp *.gml *.vtu *.stn);;GeoSys legacy files (*.gli *.msh);;All files (* *.*)"; else if (t==ImportFileType::OGS_GEO) return "OpenGeosys files (*.gml *.gli)"; else if (t==ImportFileType::OGS_STN) diff --git a/FileIO/XmlIO/Boost/BoostXmlCndInterface.cpp b/FileIO/XmlIO/Boost/BoostXmlCndInterface.cpp deleted file mode 100644 index 42709d6a96efb6595e993f8876e911442f5d097e..0000000000000000000000000000000000000000 --- a/FileIO/XmlIO/Boost/BoostXmlCndInterface.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @file BoostXmlCndInterface.cpp - * @author git blame BoostXmlCndInterface.cpp - * @date Oct 14, 2013 - * @brief - * - * @copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/LICENSE.txt - */ -#include <fstream> -#include <boost/foreach.hpp> -#include <boost/tokenizer.hpp> - -#include "logog/include/logog.hpp" - -#include "BoostXmlCndInterface.h" - -// BaseLib -#include "StringTools.h" - -// OGS -#include "BoundaryCondition.h" - -namespace FileIO -{ - -BoostXmlCndInterface::BoostXmlCndInterface(ProjectData & project_data) : - _project_data(project_data) -{} - -bool BoostXmlCndInterface::readFile(const std::string &fname) -{ - std::ifstream in(fname.c_str()); - if (!in) { - ERR("BoostXmlCndInterface::readFile(): Can't open xml-file %s.", fname.c_str()); - return false; - } - - // build DOM tree - using boost::property_tree::ptree; - ptree pt; - read_xml(in, pt); - - ptree const& root_node = pt.get_child("OpenGeoSysCond"); - - BOOST_FOREACH(ptree::value_type const & conditions_type, root_node) { - if (conditions_type.first.compare("BoundaryConditions") == 0) { - readBoundaryConditions(conditions_type.second); - } - } - - return true; -} - -void BoostXmlCndInterface::readBoundaryConditions( - boost::property_tree::ptree const& boundary_condition_nodes) -{ - using boost::property_tree::ptree; - BOOST_FOREACH(ptree::value_type const & boundary_condition_node, - boundary_condition_nodes) { - if (boundary_condition_node.first.compare("BC") != 0) - continue; - - // parse attribute of boundary condition - std::string const& geometry_name = boundary_condition_node.second.get<std::string>("<xmlattr>.geometry"); - - if (_project_data.getGEOObjects()->exists(geometry_name) == -1) { - ERR("BoostXmlCndInterface::readBoundaryConditions(): Associated geometry \"%s\" not found.", - geometry_name.c_str()); - return; - } - // create instance - BoundaryCondition *bc(new BoundaryCondition(geometry_name)); - - // parse tags of boundary condition - BOOST_FOREACH(ptree::value_type const & boundary_condition_tag, boundary_condition_node.second) { - if (boundary_condition_tag.first.compare("Process") == 0) { - std::string pcs_type, primary_variable; - readProcessTag(boundary_condition_tag.second, pcs_type, primary_variable); - bc->setProcessType(FiniteElement::convertProcessType(pcs_type)); - bc->setProcessPrimaryVariable(FiniteElement::convertPrimaryVariable(primary_variable)); - } - if (boundary_condition_tag.first.compare("Geometry") == 0) { - std::string geo_obj_type, geo_obj_name; - readGeometryTag(boundary_condition_tag.second, geo_obj_type, geo_obj_name); - bc->initGeometricAttributes(geometry_name, - GeoLib::convertGeoType(geo_obj_type), - geo_obj_name, - *(_project_data.getGEOObjects())); - } - if (boundary_condition_tag.first.compare("Distribution") == 0) { - readDistributionTag(boundary_condition_tag.second, bc); - } - } - _project_data.addCondition(bc); - } -} - -void BoostXmlCndInterface::readProcessTag(boost::property_tree::ptree const& pcs_tags, - std::string &pcs_type, std::string &primary_variable) const -{ - using boost::property_tree::ptree; - BOOST_FOREACH(ptree::value_type const & pcs_tag, pcs_tags) { - if (pcs_tag.first.compare("Type") == 0) { - pcs_type = pcs_tag.second.data(); - } - if (pcs_tag.first.compare("Variable") == 0) { - primary_variable = pcs_tag.second.data(); - } - } -} - -void BoostXmlCndInterface::readGeometryTag(boost::property_tree::ptree const& geometry_tags, - std::string &geo_type, std::string &geo_name) const -{ - using boost::property_tree::ptree; - BOOST_FOREACH(ptree::value_type const & geo_tag, geometry_tags) { - if (geo_tag.first.compare("Type") == 0) { - geo_type = geo_tag.second.data(); - } - if (geo_tag.first.compare("Name") == 0) { - geo_name = geo_tag.second.data(); - } - } -} - -void BoostXmlCndInterface::readDistributionTag(boost::property_tree::ptree const& distribution_tags, - FEMCondition * cond) const -{ - using boost::property_tree::ptree; - BOOST_FOREACH(ptree::value_type const & dis_tag, distribution_tags) { - - if (dis_tag.first.compare("Type") == 0) { - cond->setProcessDistributionType( - FiniteElement::convertDisType(dis_tag.second.data())); - } - else if (dis_tag.first.compare("Value") == 0) { - FiniteElement::DistributionType const& dt(cond->getProcessDistributionType()); - - if (dt == FiniteElement::CONSTANT || - dt == FiniteElement::CONSTANT_NEUMANN || - dt == FiniteElement::NODESCONSTANT) - { - cond->setConstantDisValue(BaseLib::str2number<double>(dis_tag.second.data())); - return; - } - - if (dt == FiniteElement::LINEAR || - dt == FiniteElement::LINEAR_NEUMANN || - dt == FiniteElement::DIRECT) - { - std::vector<std::size_t> dis_node_ids; - std::vector<double> dis_values; - - boost::tokenizer<> tok(dis_tag.second.data()); - for (boost::tokenizer<>::iterator tok_it=tok.begin(); tok_it!=tok.end(); ) { - dis_node_ids.push_back(BaseLib::str2number<std::size_t>(*tok_it)); - tok_it++; - dis_values.push_back(BaseLib::str2number<double>(*tok_it)); - tok_it++; - } - cond->setDisValues(dis_node_ids, dis_values); - return; - } - - ERR("BoostXmlCndInterface::readDistributionTag(): Distribution type not supported.") - } - } -} - -bool BoostXmlCndInterface::write() -{ - // no implementation - please use the Qt Xml writer for writing - return true; -} - -} // end namespace FileIO diff --git a/FileIO/XmlIO/Boost/BoostXmlCndInterface.h b/FileIO/XmlIO/Boost/BoostXmlCndInterface.h deleted file mode 100644 index 417fb5623e4e1072a7f58c8f08fbc2aa748d902f..0000000000000000000000000000000000000000 --- a/FileIO/XmlIO/Boost/BoostXmlCndInterface.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file BoostXmlCndInterface.h - * @author git blame BoostXmlCndInterface.h - * @date Oct 14, 2013 - * @brief Class BoostXmlCndInterface is for reading FEM conditions - * (initial, boundary conditions or source terms). Implementation uses boost. - * - * @copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/LICENSE.txt - */ -#ifndef BOOSTXMLCNDINTERFACE_H_ -#define BOOSTXMLCNDINTERFACE_H_ - -#include <string> - -#include <boost/property_tree/ptree.hpp> -#include <boost/property_tree/xml_parser.hpp> -#include <boost/optional.hpp> - -#include "../XMLInterface.h" - -class FEMCondition; -class Projectdata; - -namespace FileIO -{ - -/** - * \brief Reads and writes FEM Conditions to and from XML files using the boost XML parser. - */ -class BoostXmlCndInterface : public XMLInterface -{ -public: - explicit BoostXmlCndInterface(ProjectData & project); - virtual ~BoostXmlCndInterface() {} - - /// Reads an xml-file containing FEM Conditions such as Boundary- or Initial Conditions - bool readFile(const std::string &fname); - -protected: - /// @return true on success, else false - bool write(); - -private: - /// Read the details of a boundary condition from an xml-file - void readBoundaryConditions(boost::property_tree::ptree const& boundary_condition_nodes); - - /// Read details on process parameters - void readProcessTag(boost::property_tree::ptree const& pcs_tags, - std::string &pcs_type, std::string &primary_variable) const; - - /// Read details on geometric parameters - void readGeometryTag(boost::property_tree::ptree const& geometry_tags, - std::string &geo_type, std::string &geo_name) const; - - /// Read details on distribution parameters - void readDistributionTag(boost::property_tree::ptree const& distribution_tags, - FEMCondition * bc) const; - - ProjectData & _project_data; -}; - -} // end namespace FileIO - -#endif /* BOOSTXMLCNDINTERFACE_H_ */ diff --git a/FileIO/XmlIO/Boost/BoostXmlGmlInterface.cpp b/FileIO/XmlIO/Boost/BoostXmlGmlInterface.cpp index ca43206b9a345fde305009f3c99863938adfbf8e..d161929e52ea6a44b303c9fce14fd5dba3137e86 100644 --- a/FileIO/XmlIO/Boost/BoostXmlGmlInterface.cpp +++ b/FileIO/XmlIO/Boost/BoostXmlGmlInterface.cpp @@ -21,9 +21,6 @@ #include "logog/include/logog.hpp" -#include "ProjectData.h" -#include "GEOObjects.h" - namespace FileIO { diff --git a/FileIO/XmlIO/Boost/BoostXmlGmlInterface.h b/FileIO/XmlIO/Boost/BoostXmlGmlInterface.h index 23566746c73f9db753228de7178d4ecd6c73e405..91ac8b1a31feb637b6400ab629172b6e8bd4d742 100644 --- a/FileIO/XmlIO/Boost/BoostXmlGmlInterface.h +++ b/FileIO/XmlIO/Boost/BoostXmlGmlInterface.h @@ -24,6 +24,7 @@ #include <boost/optional.hpp> #include "../XMLInterface.h" +#include "GeoLib/GEOObjects.h" class Point; class Polyline; diff --git a/FileIO/XmlIO/Qt/XmlCndInterface.cpp b/FileIO/XmlIO/Qt/XmlCndInterface.cpp deleted file mode 100644 index 5625e08b2086b5aea74adeaa91ec5a2df8f0a7b6..0000000000000000000000000000000000000000 --- a/FileIO/XmlIO/Qt/XmlCndInterface.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-23 - * \brief Implementation of the XmlCndInterface class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "XmlCndInterface.h" - -#include <QFile> -#include <QTextCodec> -#include <QtXml/QDomDocument> -#include <QStringList> - -#include "FEMCondition.h" -#include "ProjectData.h" -#include "FileFinder.h" - - -namespace FileIO -{ -XmlCndInterface::XmlCndInterface(ProjectData &project) - : XMLInterface(), XMLQtInterface(BaseLib::FileFinder().getPath("OpenGeoSysCND.xsd")), - _type(FEMCondition::UNSPECIFIED), _project(project) -{ -} - -int XmlCndInterface::readFile(const QString &fileName) -{ - if(XMLQtInterface::readFile(fileName) == 0) - return 0; - - QDomDocument doc("OGS-Cond-DOM"); - doc.setContent(_fileData); - QDomElement docElement = doc.documentElement(); //root element, used for identifying file-type - if (docElement.nodeName().compare("OpenGeoSysCond")) - { - ERR("XMLInterface::readFEMCondFile(): Unexpected XML root."); - return 0; - } - - std::size_t const n_cond_before(this->_project.getConditions().size()); - QDomNodeList lists = docElement.childNodes(); - for (int i = 0; i < lists.count(); i++) - { - const QDomNode list_node (lists.at(i)); - const QString nodeName = list_node.nodeName(); - if (nodeName.compare("BoundaryConditions") == 0) - readConditions(list_node, FEMCondition::BOUNDARY_CONDITION); - else if (nodeName.compare("InitialConditions") == 0) - readConditions(list_node, FEMCondition::INITIAL_CONDITION); - else if (nodeName.compare("SourceTerms") == 0) - readConditions(list_node, FEMCondition::SOURCE_TERM); - } - std::size_t const n_cond_after(this->_project.getConditions().size()); - if (n_cond_after > n_cond_before) - return 1; //do something like _geoObjects->addStationVec(stations, stnName, color); - else - { - WARN("XMLInterface::readFEMCondFile(): No FEM Conditions found."); - return 0; - } - - return 1; -} - -void XmlCndInterface::readConditions(const QDomNode &listRoot, - 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(); - GeoLib::GEOTYPE geo_type; - std::string geo_obj_name; - for (int j = 0; j < geoProps.count(); j++) - { - const QString prop_name(geoProps.at(j).nodeName()); - if (prop_name.compare("Type") == 0) - geo_type = GeoLib::convertGeoType(geoProps.at(j).toElement().text().toStdString()); - else if (prop_name.compare("Name") == 0) - geo_obj_name = geoProps.at(j).toElement().text().toStdString(); - } - c->initGeometricAttributes(geometry_name, geo_type, geo_obj_name, *(_project.getGEOObjects())); - } - 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 || - c->getProcessDistributionType()==FiniteElement::NODESCONSTANT) - disValues.push_back( distProps.at(j).toElement().text().toDouble() ); - 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) - { - QString val (it->trimmed()); - if (!val.isEmpty()) - { - if (count%2==0) - disNodes.push_back(val.toInt()); - else - disValues.push_back(val.toDouble()); - count++; - } - } - } - else - ERR("XmlCndInterface::readConditions(): Distribution type not supported."); - c->setDisValues(disNodes, disValues); - } - } - } - } - this->_project.addCondition(c); - } - else - { - ERR("XmlCndInterface::readConditions(): No geometry \"%s\" found.", geometry_name.c_str()); - } - cond = cond.nextSiblingElement(); - } -} - -bool XmlCndInterface::write() -{ - _out << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; // xml definition - _out << "<?xml-stylesheet type=\"text/xsl\" href=\"OpenGeoSysCND.xsl\"?>\n\n"; // stylefile definition - - QDomDocument doc("OGS-CND-DOM"); - QDomElement root = doc.createElement("OpenGeoSysCond"); - root.setAttribute( "xmlns:ogs", "http://www.opengeosys.org" ); - root.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - root.setAttribute( "xsi:noNamespaceSchemaLocation", "http://www.opengeosys.org/images/xsd/OpenGeoSysCND.xsd" ); - - std::vector<FEMCondition*> const& conditions (_project.getConditions( - FiniteElement::INVALID_PROCESS, - _exportName, - _type) ); - - if (conditions.empty()) - return 1; - - const QString export_name (QString::fromStdString(_exportName)); - doc.appendChild(root); - - size_t nConditions (conditions.size()); - - // create root nodes for various conditions types if there is at least one condition of that type - QDomElement ic_root, bc_root, st_root; - if (std::find_if(conditions.begin(), conditions.end(), - [](FEMCondition const*const cond){return cond->getCondType() == FEMCondition::INITIAL_CONDITION;}) != conditions.end()) - ic_root = this->getCondListElement(doc, root, "InitialConditions"); - if (std::find_if(conditions.begin(), conditions.end(), - [](FEMCondition const*const cond){return cond->getCondType() == FEMCondition::BOUNDARY_CONDITION; }) != conditions.end()) - bc_root = this->getCondListElement(doc, root, "BoundaryConditions"); - if (std::find_if(conditions.begin(), conditions.end(), - [](FEMCondition const*const cond){return cond->getCondType() == FEMCondition::SOURCE_TERM; }) != conditions.end()) - st_root = this->getCondListElement(doc, root, "SourceTerms"); - - for (size_t i = 0; i < nConditions; i++) - { - FEMCondition::CondType current_type = conditions[i]->getCondType(); - if (current_type == _type || _type == FEMCondition::UNSPECIFIED) - { - QDomElement listTag; - QString condText; - - if (current_type == FEMCondition::BOUNDARY_CONDITION) - { - listTag = bc_root; - condText = "BC"; - } - else if (current_type == FEMCondition::INITIAL_CONDITION) - { - listTag = ic_root; - condText = "IC"; - } - else if (current_type == FEMCondition::SOURCE_TERM) - { - listTag = st_root; - condText = "ST"; - } - else - { - ERR("XmlCndInterface::writeFile(): Unspecified FEMConditions found ... Abort writing."); - return 0; - } - this->writeCondition(doc, listTag, conditions[i], condText, export_name); - } - } - std::string xml = doc.toString().toStdString(); - _out << xml; - - return true; -} - -void XmlCndInterface::writeCondition(QDomDocument doc, QDomElement &listTag, - const FEMCondition* cond, const QString &condText, - const QString &geometryName) const -{ - QString geoName (QString::fromStdString(cond->getAssociatedGeometryName())); - - if ((geometryName.length() > 0) && (geoName.compare(geometryName) != 0)) - { - WARN("XmlCndInterface::writeCondition(): Geometry name not matching, skipping condition \"%s\".", - cond->getGeoName().c_str()); - return; - } - - QDomElement condTag ( doc.createElement(condText) ); - condTag.setAttribute("geometry", geoName); - listTag.appendChild(condTag); - - QDomElement processTag ( doc.createElement("Process") ); - condTag.appendChild(processTag); - QDomElement processTypeTag ( doc.createElement("Type") ); - processTag.appendChild(processTypeTag); - QDomText processTypeText ( doc.createTextNode( - QString::fromStdString(FiniteElement::convertProcessTypeToString(cond->getProcessType()))) ); - processTypeTag.appendChild(processTypeText); - QDomElement processPVTag ( doc.createElement("Variable") ); - processTag.appendChild(processPVTag); - QDomText processPVText ( doc.createTextNode( - QString::fromStdString(FiniteElement::convertPrimaryVariableToString(cond->getProcessPrimaryVariable()))) ); - processPVTag.appendChild(processPVText); - - QDomElement geoTag ( doc.createElement("Geometry") ); - condTag.appendChild(geoTag); - QDomElement geoTypeTag ( doc.createElement("Type") ); - geoTag.appendChild(geoTypeTag); - QDomText geoTypeText ( doc.createTextNode( - QString::fromStdString(GeoLib::convertGeoTypeToString(cond->getGeomType()))) ); - geoTypeTag.appendChild(geoTypeText); - QDomElement geoNameTag ( doc.createElement("Name") ); - geoTag.appendChild(geoNameTag); - QString geo_obj_name ( QString::fromStdString(cond->getGeoName()) ); - QDomText geoNameText ( doc.createTextNode(geo_obj_name) ); - geoNameTag.appendChild(geoNameText); - - QDomElement disTag ( doc.createElement("Distribution") ); - condTag.appendChild(disTag); - QDomElement disTypeTag ( doc.createElement("Type") ); - disTag.appendChild(disTypeTag); - QDomText disTypeText ( doc.createTextNode( - QString::fromStdString(FiniteElement::convertDisTypeToString(cond->getProcessDistributionType()))) ); - disTypeTag.appendChild(disTypeText); - QDomElement disValueTag ( doc.createElement("Value") ); - disTag.appendChild(disValueTag); - /* - if (cond->getProcessDistributionType() != FiniteElement::DIRECT) - { - double dis_value (cond->getDisValue()[0]); //TODO: do this correctly! - disValueText = doc.createTextNode(QString::number(dis_value)); - } - else - disValueText = doc.createTextNode(QString::fromStdString(cond->getDirectFileName())); - */ - const std::vector<size_t> dis_nodes = cond->getDisNodes(); - const std::vector<double> dis_values = cond->getDisValues(); - const size_t nNodes = dis_nodes.size(); - const size_t nValues = dis_values.size(); - std::stringstream ss; - if (nNodes == 0 && nValues == 1) // CONSTANT - ss << dis_values[0]; - else if ((nValues > 0) && (nValues == nNodes)) // LINEAR && DIRECT - { - ss << "\n\t"; - for (size_t i = 0; i < nValues; i++) - ss << dis_nodes[i] << "\t" << dis_values[i] << "\n\t"; - } - else - { - ERR("XmlCndInterface::writeCondition(): Inconsistent length of distribution value array."); - ss << "-9999"; - } - QDomText disValueText = doc.createTextNode(QString::fromStdString(ss.str())); - disValueTag.appendChild(disValueText); -} - -QDomElement XmlCndInterface::getCondListElement(QDomDocument doc, QDomElement &root, - const QString &text) const -{ - const QDomNodeList list = root.elementsByTagName(text); - if (list.isEmpty()) { - QDomElement newListTag(doc.createElement(text)); - root.appendChild(newListTag); - return newListTag; - } - return list.at(0).toElement(); -} -} diff --git a/FileIO/XmlIO/Qt/XmlCndInterface.h b/FileIO/XmlIO/Qt/XmlCndInterface.h deleted file mode 100644 index 9e664a284bef16f444805beb4cc07e924a29407f..0000000000000000000000000000000000000000 --- a/FileIO/XmlIO/Qt/XmlCndInterface.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-23 - * \brief Definition of the XmlCndInterface class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef XMLCNDINTERFACE_H -#define XMLCNDINTERFACE_H - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -// FileIO/XmlIO -#include "../XMLInterface.h" -#include "XMLQtInterface.h" - -class FEMCondition; -class ProjectData; - -namespace FileIO -{ -/** - * \brief Reads and writes FEM Conditions to and from XML files using the Qt XML parser and validator. - */ -class XmlCndInterface : public XMLInterface, public XMLQtInterface -{ -public: - /** - * Constructor - * \param project Project data. - */ - XmlCndInterface(ProjectData &project); - - ~XmlCndInterface() {} - - /// Reads an xml-file containing FEM Conditions such as Boundary- or Initial Conditions - int readFile(const QString &fileName); - - /// Reads an xml-file containing FEM Conditions (convenience function for using std::strings) - bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } - - /// Sets the type of condition to be written to a file. - void setConditionType(FEMCondition::CondType type) { _type = type; } - -protected: - bool write(); - -private: - /// Read the details of various FEM Conditions from an xml-file - void readConditions(const QDomNode &condRoot, FEMCondition::CondType type); - - /// Returns the root node for the kind of FEM Condition specified by condText - QDomElement getCondListElement(QDomDocument doc, QDomElement &root, - const QString &condText) const; - - /// Writes a FEM condition to an xml-file using the write() method - void writeCondition(QDomDocument doc, QDomElement &listTag, const FEMCondition* cond, - const QString &condText, const QString &geoName) const; - - FEMCondition::CondType _type; - - ProjectData& _project; -}; -} - -#endif // XMLCNDINTERFACE_H diff --git a/FileIO/XmlIO/Qt/XmlGmlInterface.h b/FileIO/XmlIO/Qt/XmlGmlInterface.h index 768b18fc9019155a0b445defca09b22e642307b3..af8ed3f17e7bf90abea880b132de125d099d2ef6 100644 --- a/FileIO/XmlIO/Qt/XmlGmlInterface.h +++ b/FileIO/XmlIO/Qt/XmlGmlInterface.h @@ -18,6 +18,8 @@ #include "../XMLInterface.h" #include "XMLQtInterface.h" +#include "GeoLib/GEOObjects.h" + namespace FileIO { @@ -27,10 +29,6 @@ namespace FileIO class XmlGmlInterface : public XMLInterface, public XMLQtInterface { public: - /** - * Constructor - * \param project Project data. - */ XmlGmlInterface(GeoLib::GEOObjects& geo_objs); virtual ~XmlGmlInterface() {} diff --git a/FileIO/XmlIO/Qt/XmlGspInterface.cpp b/FileIO/XmlIO/Qt/XmlGspInterface.cpp index de0adda251f88ab5e0a64788dd363887d51bae57..809e122edcf4d2a6f6b1ef9befc87cece8ca4c7b 100644 --- a/FileIO/XmlIO/Qt/XmlGspInterface.cpp +++ b/FileIO/XmlIO/Qt/XmlGspInterface.cpp @@ -17,7 +17,6 @@ #include "XmlGspInterface.h" -#include "XmlCndInterface.h" #include "XmlGmlInterface.h" #include "XmlStnInterface.h" @@ -95,13 +94,6 @@ int XmlGspInterface::readFile(const QString &fileName) if (msh) _project.addMesh(msh); } - else if (file_node.compare("cnd") == 0) - { - const std::string cnd_name = path.toStdString() + - fileList.at(i).toElement().text().toStdString(); - XmlCndInterface cnd(_project); - cnd.readFile(cnd_name); - } } return 1; @@ -197,26 +189,6 @@ bool XmlGspInterface::write() ERR("XmlGspInterface::writeFile(): Error writing stn-file \"%s\".", name.c_str()); } - // CND - const std::vector<FEMCondition*> &cnd_vec (_project.getConditions()); - if (!cnd_vec.empty()) - { - XmlCndInterface cnd(_project); - const std::string cnd_name (BaseLib::extractBaseNameWithoutExtension(_filename) + ".cnd"); - if (cnd.writeToFile(path + cnd_name)) - { - // write entry in project file - QDomElement cndTag = doc.createElement("cnd"); - root.appendChild(cndTag); - QDomElement fileNameTag = doc.createElement("file"); - cndTag.appendChild(fileNameTag); - QDomText fileNameText = doc.createTextNode(QString::fromStdString(cnd_name)); - fileNameTag.appendChild(fileNameText); - } - else - ERR("XmlGspInterface::writeFile(): Error writing cnd-file \"%s\".", cnd_name.c_str()); - } - std::string xml = doc.toString().toStdString(); _out << xml; return true; diff --git a/FileIO/XmlIO/Qt/XmlGspInterface.h b/FileIO/XmlIO/Qt/XmlGspInterface.h index 7c242995dc2ddb81e5d80be25c71e7d284d9185f..efbb415d0b7af0a12ffa770ffc553c1fbb686e84 100644 --- a/FileIO/XmlIO/Qt/XmlGspInterface.h +++ b/FileIO/XmlIO/Qt/XmlGspInterface.h @@ -18,6 +18,8 @@ #include "../XMLInterface.h" #include "XMLQtInterface.h" +#include "Applications/ProjectData.h" + namespace FileIO { diff --git a/FileIO/XmlIO/Qt/XmlNumInterface.cpp b/FileIO/XmlIO/Qt/XmlNumInterface.cpp index a2c37de3cff8d3379b21d614aabff35ed7679968..c675c25fa1e15797624c56784284344098546c5c 100644 --- a/FileIO/XmlIO/Qt/XmlNumInterface.cpp +++ b/FileIO/XmlIO/Qt/XmlNumInterface.cpp @@ -24,8 +24,8 @@ namespace FileIO { -XmlNumInterface::XmlNumInterface(ProjectData &project) : - XMLInterface(), XMLQtInterface(BaseLib::FileFinder().getPath("OpenGeoSysNUM.xsd")), _project(project) +XmlNumInterface::XmlNumInterface() : + XMLInterface(), XMLQtInterface(BaseLib::FileFinder().getPath("OpenGeoSysNUM.xsd")) { } diff --git a/FileIO/XmlIO/Qt/XmlNumInterface.h b/FileIO/XmlIO/Qt/XmlNumInterface.h index 699ab0de150cdaefbc87180f2617ca04fa77d74c..34853b5ff14a591f0bfc4c97bc9305156875fb4a 100644 --- a/FileIO/XmlIO/Qt/XmlNumInterface.h +++ b/FileIO/XmlIO/Qt/XmlNumInterface.h @@ -21,21 +21,13 @@ namespace FileIO { -/** - * \brief Reads and writes GeoObjects to and from XML files. - */ class XmlNumInterface : public XMLInterface, public XMLQtInterface { public: - /** - * Constructor - * \param project Project data. - */ - XmlNumInterface(ProjectData &project); + XmlNumInterface(); virtual ~XmlNumInterface() {} - /// Reads an xml-file containing geometric object definitions into the GEOObjects used in the contructor int readFile(QString const& fileName); bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } @@ -46,8 +38,6 @@ protected: void readConvergenceCriteria(QDomElement const& convergence_root); bool write(); -private: - ProjectData &_project; }; } diff --git a/FileIO/XmlIO/Qt/XmlStnInterface.h b/FileIO/XmlIO/Qt/XmlStnInterface.h index ed1519e974d1eeaa9a70249ff772ba1cef472259..db97cc9a94e7c46e4ece30ab9a54f2baf20c90d8 100644 --- a/FileIO/XmlIO/Qt/XmlStnInterface.h +++ b/FileIO/XmlIO/Qt/XmlStnInterface.h @@ -20,6 +20,8 @@ #include "../XMLInterface.h" #include "XMLQtInterface.h" +#include "GeoLib/GEOObjects.h" + namespace GeoLib { class StationBorehole; } @@ -33,10 +35,6 @@ namespace FileIO class XmlStnInterface : public XMLInterface, public XMLQtInterface { public: - /** - * Constructor - * \param project Project data. - */ XmlStnInterface(GeoLib::GEOObjects& geo_objs); /// Reads an xml-file containing station object definitions into the GEOObjects used in the contructor (requires Qt) diff --git a/FileIO/XmlIO/XMLInterface.h b/FileIO/XmlIO/XMLInterface.h index 50c898d07f3b11efc07c7032cb78a0c080d41071..6e9acfe5d66d266a3aed5608aa468c3bd49ce843 100644 --- a/FileIO/XmlIO/XMLInterface.h +++ b/FileIO/XmlIO/XMLInterface.h @@ -15,8 +15,6 @@ #ifndef XMLINTERFACE_H #define XMLINTERFACE_H -#include "OGS/ProjectData.h" - #include "FileIO/Writer.h" namespace FileIO diff --git a/Gui/DataExplorer.cmake b/Gui/DataExplorer.cmake index e83745cb494f0134af535e9f10bd3e8a56534c98..7b90a8624789e0747daad91252979b869ec213cd 100644 --- a/Gui/DataExplorer.cmake +++ b/Gui/DataExplorer.cmake @@ -37,7 +37,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../FileIO ${CMAKE_CURRENT_SOURCE_DIR}/../MeshLib ${CMAKE_CURRENT_SOURCE_DIR}/../MeshLibGEOTOOLS - ${CMAKE_CURRENT_SOURCE_DIR}/../OGS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Base ${CMAKE_CURRENT_BINARY_DIR}/DataView @@ -70,12 +69,12 @@ ADD_EXECUTABLE( ogs-gui MACOSX_BUNDLE TARGET_LINK_LIBRARIES( ogs-gui ${QT_LIBRARIES} + ApplicationsLib BaseLib GeoLib FileIO MeshLib #MSHGEOTOOLS - OgsLib QtBase QtDataView StratView diff --git a/Gui/DataView/CMakeLists.txt b/Gui/DataView/CMakeLists.txt index 9e88241253a734c28c84319ce8d264b7c9099303..3e820c31f005a59190831cfc38506f20aecb19f4 100644 --- a/Gui/DataView/CMakeLists.txt +++ b/Gui/DataView/CMakeLists.txt @@ -3,12 +3,10 @@ set( SOURCES ColorTableModel.cpp ColorTableView.cpp CondFromRasterDialog.cpp - ConditionWriterDialog.cpp DataExplorerSettingsDialog.cpp DirectConditionGenerator.cpp ElementTreeModel.cpp ElementTreeView.cpp - FEMConditionSetupDialog.cpp GeoMapper.cpp GEOModels.cpp GeoOnMeshMappingDialog.cpp @@ -33,9 +31,6 @@ set( SOURCES MshTabWidget.cpp MshView.cpp NetCdfConfigureDialog.cpp - NewProcessDialog.cpp - ProcessModel.cpp - ProcessView.cpp SelectMeshDialog.cpp SetNameDialog.cpp SHPImportDialog.cpp @@ -49,11 +44,9 @@ set( MOC_HEADERS ColorTableModel.h ColorTableView.h CondFromRasterDialog.h - ConditionWriterDialog.h DataExplorerSettingsDialog.h ElementTreeModel.h ElementTreeView.h - FEMConditionSetupDialog.h GEOModels.h GeoOnMeshMappingDialog.h GeoTabWidget.h @@ -75,9 +68,6 @@ set( MOC_HEADERS MshTabWidget.h MshView.h NetCdfConfigureDialog.h - NewProcessDialog.h - ProcessModel.h - ProcessView.h SelectMeshDialog.h SetNameDialog.h SHPImportDialog.h @@ -97,7 +87,6 @@ set( HEADERS GeoTreeItem.h ModelTreeItem.h MshItem.h - ProcessItem.h ) # UI files @@ -149,7 +138,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../BaseLib ${CMAKE_CURRENT_SOURCE_DIR}/../../MathLib ${CMAKE_CURRENT_SOURCE_DIR}/../../GeoLib - ${CMAKE_CURRENT_SOURCE_DIR}/../../OGS ${CMAKE_CURRENT_SOURCE_DIR}/../../MeshLib ${CMAKE_CURRENT_SOURCE_DIR}/../../FileIO ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Gui/DataView/CondFromRasterDialog.h b/Gui/DataView/CondFromRasterDialog.h index c2917ec6339550ba117e9ea641575684b5c74439..7b12e04e0c6e571aaa24d222bb5e92f6ef7cf9a2 100644 --- a/Gui/DataView/CondFromRasterDialog.h +++ b/Gui/DataView/CondFromRasterDialog.h @@ -18,7 +18,7 @@ #include "ui_CondFromRaster.h" #include <QDialog> -#include "ProjectData.h" +#include "Applications/ProjectData.h" namespace MeshLib { class Mesh; diff --git a/Gui/DataView/ConditionWriterDialog.cpp b/Gui/DataView/ConditionWriterDialog.cpp deleted file mode 100644 index b03fef910aab226cd7ef1e4debbe28ccedb36287..0000000000000000000000000000000000000000 --- a/Gui/DataView/ConditionWriterDialog.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2012-01-11 - * \brief Implementation of the ConditionWriterDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "ConditionWriterDialog.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -#include "FEMCondition.h" -#include "OGSError.h" -#include "LastSavedFileDirectory.h" - -#include <QFileDialog> -#include <QFileInfo> -#include <QSettings> - -ConditionWriterDialog::ConditionWriterDialog(const GeoLib::GEOObjects *geo_objects, QDialog* parent) - : QDialog(parent) -{ - setupUi(this); - - std::vector<std::string> geo_names; - geo_objects->getGeometryNames(geo_names); - - for (size_t i=0; i<geo_names.size(); i++) - this->geoBox->addItem(QString::fromStdString(geo_names[i])); -} - -ConditionWriterDialog::~ConditionWriterDialog() -{ -} - -void ConditionWriterDialog::on_fileNameButton_pressed() -{ - QSettings settings; - QString fileName = QFileDialog::getSaveFileName(this, "Select path", - LastSavedFileDirectory::getDir(), "OpenGeoSys FEM Condition file (*.cnd)"); - - if (!fileName.isEmpty()) - this->fileNameEdit->setText(fileName); -} - -void ConditionWriterDialog::accept() -{ - const QString file_name = this->fileNameEdit->text(); - QFileInfo fi(file_name); - - QString geo_name = this->geoBox->currentText(); - if (this->geoBox->currentIndex() == 0) geo_name = ""; - - FEMCondition::CondType cond_type(FEMCondition::UNSPECIFIED);; - switch (this->condTypeBox->currentIndex()) - { - case 0: - cond_type = FEMCondition::UNSPECIFIED; break; - case 1: - cond_type = FEMCondition::BOUNDARY_CONDITION; break; - case 2: - cond_type = FEMCondition::INITIAL_CONDITION; break; - case 3: - cond_type = FEMCondition::SOURCE_TERM; break; - default: - ERR("ConditionWriterDialog::accept(): case %d not handled.", this->condTypeBox->currentIndex()); - } - - LastSavedFileDirectory::setDir(file_name); - emit saveFEMConditionsRequested(geo_name, cond_type, file_name); - - this->done(QDialog::Accepted); -} - -void ConditionWriterDialog::reject() -{ - this->done(QDialog::Rejected); -} - diff --git a/Gui/DataView/ConditionWriterDialog.h b/Gui/DataView/ConditionWriterDialog.h deleted file mode 100644 index c1445133c1ec327ef01bfc576488459fc8416e10..0000000000000000000000000000000000000000 --- a/Gui/DataView/ConditionWriterDialog.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2012-01-11 - * \brief Definition of the ConditionWriterDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef CONDITIONWRITERDIALOG_H -#define CONDITIONWRITERDIALOG_H - -#include "ui_ConditionWriter.h" -#include <QDialog> - -#include "GEOObjects.h" -#include "FEMCondition.h" - -/** - * \brief A dialog window for creating DIRECT boundary conditions from raster files - */ -class ConditionWriterDialog : public QDialog, private Ui_ConditionWriter -{ - Q_OBJECT - -public: - ConditionWriterDialog(const GeoLib::GEOObjects* geoObjects, QDialog* parent = 0); - ~ConditionWriterDialog(void); - -private slots: - void on_fileNameButton_pressed(); - - /// Instructions if the OK-Button has been pressed. - void accept(); - - /// Instructions if the Cancel-Button has been pressed. - void reject(); - -signals: - void saveFEMConditionsRequested(const QString&, const FEMCondition::CondType, const QString&); - -}; - -#endif //CONDITIONWRITERDIALOG_H diff --git a/Gui/DataView/FEMConditionSetupDialog.cpp b/Gui/DataView/FEMConditionSetupDialog.cpp deleted file mode 100644 index 7d1fbe170937efd89d05581b3769669ba0394b22..0000000000000000000000000000000000000000 --- a/Gui/DataView/FEMConditionSetupDialog.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-07 - * \brief Implementation of the FEMConditionSetupDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "FEMConditionSetupDialog.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -#include "OGSError.h" -#include "FEMEnums.h" -#include "ProjectData.h" -#include "StrictDoubleValidator.h" -#include "LinearEditDialog.h" -#include "CondFromRasterDialog.h" - -#include "BoundaryCondition.h" -#include "InitialCondition.h" -#include "SourceTerm.h" - - -FEMConditionSetupDialog::FEMConditionSetupDialog(const std::string &associated_geometry, - const GeoLib::GEOTYPE type, - const std::string &geo_name, - const GeoLib::GeoObject* const geo_object, - bool on_points, - QDialog* parent) -: QDialog(parent), _cond(associated_geometry, FEMCondition::UNSPECIFIED), _set_on_points(on_points), - _combobox(nullptr), directButton(nullptr), _mesh(nullptr), _first_value_validator(nullptr) -{ - _cond.setGeoType(type); - _cond.setGeoName(geo_name); - _cond.setGeoObj(geo_object); - - setupUi(this); - setupDialog(); -} - -FEMConditionSetupDialog::FEMConditionSetupDialog(const FEMCondition &cond, QDialog* parent) - : QDialog(parent), _cond(cond), _set_on_points(false), _combobox(nullptr), directButton(nullptr), - _mesh(nullptr), _first_value_validator(nullptr) -{ - setupUi(this); - setupDialog(); - setValuesFromCond(); -} - -FEMConditionSetupDialog::FEMConditionSetupDialog(const std::string &name, const MeshLib::Mesh* mesh, QDialog* parent) -: QDialog(parent), _cond(name, FEMCondition::UNSPECIFIED), _set_on_points(false), _combobox(nullptr), directButton(nullptr), - _mesh(mesh), _first_value_validator(nullptr) -{ - _cond.setGeoType(GeoLib::GEOTYPE::INVALID); - _cond.setGeoName(name); - _cond.setGeoObj(nullptr); - - setupUi(this); - setupDialog(); -} - -FEMConditionSetupDialog::~FEMConditionSetupDialog() -{ - delete _combobox; - delete directButton; - delete _first_value_validator; -} - -void FEMConditionSetupDialog::setupDialog() -{ - if (_cond.getGeomType() != GeoLib::GEOTYPE::INVALID) - { - this->disTypeBox->addItem("Constant (Dirichlet)"); - if (_cond.getGeomType() == GeoLib::GEOTYPE::POLYLINE) - this->disTypeBox->addItem("Linear (Dirichlet)"); - - if (this->_set_on_points) - { - _combobox = new QComboBox; - _combobox->addItem("Elevation"); - static_cast<QGridLayout*>(this->layout())->addWidget(_combobox,5,1) ; - } - else - { - _first_value_validator = new StrictDoubleValidator(-1e+10, 1e+10, 5); - this->firstValueEdit->setText("0"); - this->firstValueEdit->setValidator (_first_value_validator); - } - } - else // direct on mesh - { - this->disTypeBox->addItem("Direct"); - this->setValueInputWidget(true); - this->condTypeBox->setCurrentIndex(2); - } - - const std::list<std::string> process_names = FiniteElement::getAllProcessNames(); - for (std::list<std::string>::const_iterator it = process_names.begin(); it != process_names.end(); ++it) - this->processTypeBox->addItem(QString::fromStdString(*it)); - - const std::list<std::string> pv_names = FiniteElement::getAllPrimaryVariableNames(); - for (std::list<std::string>::const_iterator it = pv_names.begin(); it != pv_names.end(); ++it) - this->pvTypeBox->addItem(QString::fromStdString(*it)); -/* - const std::list<std::string> dis_names = FiniteElement::getAllDistributionNames(); - for (std::list<std::string>::const_iterator it = dis_names.begin(); it != dis_names.end(); ++it) - this->disTypeBox->addItem(QString::fromStdString(*it)); -*/ -} - -void FEMConditionSetupDialog::setValuesFromCond() -{ - QString pcs_type = QString::fromStdString(FiniteElement::convertProcessTypeToString(_cond.getProcessType())); - this->processTypeBox->setCurrentIndex(this->processTypeBox->findText(pcs_type)); - - QString pv_type = QString::fromStdString(FiniteElement::convertPrimaryVariableToString(_cond.getProcessPrimaryVariable())); - this->pvTypeBox->setCurrentIndex(this->pvTypeBox->findText(pv_type)); - - if (_cond.getCondType() == FEMCondition::INITIAL_CONDITION) - this->condTypeBox->setCurrentIndex(1); - else if (_cond.getCondType() == FEMCondition::SOURCE_TERM) - { - this->condTypeBox->setCurrentIndex(2); - on_condTypeBox_currentIndexChanged(2); - } - - if (_cond.getGeomType() != GeoLib::GEOTYPE::INVALID) - { - if (_cond.getProcessDistributionType() == FiniteElement::CONSTANT || _cond.getProcessDistributionType() == FiniteElement::CONSTANT_NEUMANN) - { - this->disTypeBox->setCurrentIndex(0); - this->firstValueEdit->setText(QString::number(_cond.getDisValues()[0])); - } - else - { - this->disTypeBox->setCurrentIndex(1); - directButton = new QPushButton(QString::number(static_cast<int>(_cond.getDisValues().size())) + " values"); - } - } - else // direct on mesh - { - this->directButton->setText(QString::number(static_cast<int>(_cond.getDisValues().size())) + " values"); - } -} - - -void FEMConditionSetupDialog::accept() -{ - _cond.setProcessType(static_cast<FiniteElement::ProcessType>(this->processTypeBox->currentIndex() + 1)); - _cond.setProcessPrimaryVariable(static_cast<FiniteElement::PrimaryVariable>(this->pvTypeBox->currentIndex() + 1)); - - if (_cond.getGeomType() != GeoLib::GEOTYPE::INVALID) - { - if (condTypeBox->currentIndex()>1) // ST - { - if (this->disTypeBox->currentIndex()>0) - _cond.setProcessDistributionType(FiniteElement::LINEAR_NEUMANN); - else - { - _cond.setProcessDistributionType(FiniteElement::CONSTANT_NEUMANN); - _cond.setConstantDisValue(this->firstValueEdit->text().toDouble()); - } - } - else // BC or IC - { - if (this->disTypeBox->currentIndex()>0) - _cond.setProcessDistributionType(FiniteElement::LINEAR); - else - { - _cond.setProcessDistributionType(FiniteElement::CONSTANT); - _cond.setConstantDisValue(this->firstValueEdit->text().toDouble()); - } - } - } - else // direct on mesh - { - if (this->condTypeBox->currentIndex()==1) // IC - { - _cond.setProcessDistributionType(FiniteElement::NODESCONSTANT); - _cond.setConstantDisValue(this->firstValueEdit->text().toDouble()); - } - else // BC or ST - _cond.setProcessDistributionType(FiniteElement::DIRECT); - } - if (_cond.getDisValues().size()==0) - { - OGSError::box("No distribution values specified!"); - return; - } - - if (!_set_on_points) - { - std::vector<FEMCondition*> conditions; - conditions.push_back(this->typeCast(_cond)); - emit createFEMCondition(conditions); - } - else - this->copyCondOnPoints(); - - this->done(QDialog::Accepted); -} - -void FEMConditionSetupDialog::reject() -{ - this->done(QDialog::Rejected); -} - - -void FEMConditionSetupDialog::on_condTypeBox_currentIndexChanged(int index) -{ - //if (index==1) - // this->geoNameBox->addItem("Domain"); - // remove "Domain" if IC is unselected - if (_cond.getGeomType() != GeoLib::GEOTYPE::INVALID) - { - if (index>1) // source terms selected - { - this->clearDisTypeBox(); - this->disTypeBox->addItem("Constant (Neumann)"); - if (_cond.getGeomType() == GeoLib::GEOTYPE::POLYLINE) - this->disTypeBox->addItem("Linear (Neumann)"); - } - else - { - this->clearDisTypeBox(); - this->disTypeBox->addItem("Constant (Dirichlet)"); - if (_cond.getGeomType() == GeoLib::GEOTYPE::POLYLINE) - this->disTypeBox->addItem("Linear (Dirichlet)"); - } - } - else { - if (index==1) // initial condition selected - { - this->clearDisTypeBox(); - this->disTypeBox->addItem("Domain"); - this->setValueInputWidget(false); - } - else - { - this->clearDisTypeBox(); - this->disTypeBox->addItem("Direct"); - this->setValueInputWidget(true); - } - } -} - - -void FEMConditionSetupDialog::on_disTypeBox_currentIndexChanged(int index) -{ - this->setValueInputWidget(index>0); -} - -void FEMConditionSetupDialog::setValueInputWidget(bool is_button) -{ - if (is_button || _cond.getGeomType() == GeoLib::GEOTYPE::INVALID) // linear or direct - { - static_cast<QGridLayout*>(this->layout())->removeWidget(this->firstValueEdit); - delete firstValueEdit; - firstValueEdit = nullptr; - directButton = new QPushButton("Calculate Values"); - connect(this->directButton, SIGNAL(pressed()), this, SLOT(directButton_pressed())); - static_cast<QGridLayout*>(this->layout())->addWidget(directButton,5,1); - } - else // constant or domain - { - static_cast<QGridLayout*>(this->layout())->removeWidget(this->directButton); - delete directButton; - directButton = nullptr; - firstValueEdit = new QLineEdit("0"); - this->firstValueEdit->setValidator (_first_value_validator); - static_cast<QGridLayout*>(this->layout())->addWidget(this->firstValueEdit,5,1); - } -} - -void FEMConditionSetupDialog::directButton_pressed() -{ - if (this->_mesh == nullptr) - { - const GeoLib::Polyline* line = dynamic_cast<const GeoLib::Polyline*>(_cond.getGeoObj()); - const std::vector<size_t> nodes = _cond.getDisNodes(); - const std::vector<double> values = _cond.getDisValues(); - LinearEditDialog dlg(*line, nodes, values); - connect(&dlg, SIGNAL(transmitDisValues(std::vector< std::pair<std::size_t,double> >)), - this, SLOT(addDisValues(std::vector< std::pair<std::size_t,double> >))); - dlg.exec(); - } - else - { - std::vector<MeshLib::Mesh*> msh_vec; - msh_vec.push_back( const_cast<MeshLib::Mesh*>(this->_mesh) ); - CondFromRasterDialog dlg(msh_vec); - //connect(&dlg, SIGNAL(directNodesWritten(std::string)), this, SLOT(direct_path_changed(std::string))); - connect(&dlg, SIGNAL(transmitDisValues(std::vector< std::pair<std::size_t,double> >)), - this, SLOT(addDisValues(std::vector< std::pair<std::size_t,double> >))); - dlg.exec(); - } -} - -void FEMConditionSetupDialog::addDisValues(std::vector< std::pair<size_t,double> > direct_values) -{ - _cond.setDisValues(direct_values); - this->directButton->setText(QString::number(direct_values.size()) + " values added"); -} - -FEMCondition* FEMConditionSetupDialog::typeCast(const FEMCondition &cond) -{ - FEMCondition* new_cond(nullptr); - switch(this->condTypeBox->currentIndex()) - { - case 0: - new_cond = new BoundaryCondition(cond); - break; - case 1: - new_cond = new InitialCondition(cond); - break; - default: - new_cond = new SourceTerm(cond); - } - return new_cond; -} - -void FEMConditionSetupDialog::copyCondOnPoints() -{ - std::vector<FEMCondition*> conditions; - if (_cond.getGeomType() == GeoLib::GEOTYPE::POLYLINE) - { - const GeoLib::Polyline* ply = dynamic_cast<const GeoLib::Polyline*>(_cond.getGeoObj()); - size_t nPoints = ply->getNumberOfPoints(); - for (size_t i=0; i<nPoints; i++) - { - FEMCondition* cond = new FEMCondition(_cond); - cond->setGeoObj(nullptr); - cond->setGeoType(GeoLib::GEOTYPE::POINT); - cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + std::to_string(ply->getPointID(i))); - cond->clearDisValues(); - cond->setConstantDisValue((*ply->getPoint(i))[2]); - conditions.push_back(this->typeCast(*cond)); - } - emit createFEMCondition(conditions); - } - else if (_cond.getGeomType() == GeoLib::GEOTYPE::SURFACE) - { - const GeoLib::Surface* sfc = dynamic_cast<const GeoLib::Surface*>(_cond.getGeoObj()); - size_t nTriangles = sfc->getNTriangles(); - for (size_t i=0; i<nTriangles; i++) - { - const GeoLib::Triangle* tri = (*sfc)[i]; - for (size_t j=0; j<3; j++) - { - FEMCondition* cond = new FEMCondition(_cond); - cond->setGeoObj(nullptr); - cond->setGeoType(GeoLib::GEOTYPE::POINT); - cond->setGeoName(_cond.getAssociatedGeometryName() + "_Point" + std::to_string((*tri)[j])); - cond->clearDisValues(); - cond->setConstantDisValue((*tri->getPoint(j))[2]); - conditions.push_back(this->typeCast(*cond)); - } - } - emit createFEMCondition(conditions); - } - else - ERR("FEMConditionSetupDialog::copyCondOnPoints(): discerning GeoType."); -} - -void FEMConditionSetupDialog::clearDisTypeBox() -{ - while (this->disTypeBox->count()>0) - this->disTypeBox->removeItem(0); -} diff --git a/Gui/DataView/FEMConditionSetupDialog.h b/Gui/DataView/FEMConditionSetupDialog.h deleted file mode 100644 index 2742553d10f2949a782aede64e60cb3b3379dd7d..0000000000000000000000000000000000000000 --- a/Gui/DataView/FEMConditionSetupDialog.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-07 - * \brief Definition of the FEMConditionSetupDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef FEMCONDITIONSETUPDIALOG_H -#define FEMCONDITIONSETUPDIALOG_H - -#include "ui_FEMConditionSetup.h" -#include "FEMCondition.h" - -#include <QDialog> - -class QComboBox; -class QPushButton; -class StrictDoubleValidator; - -namespace GeoLib { - class GeoObject; -} - -namespace MeshLib { - class Mesh; -} - -/** - * \brief A dialog window for adding FEM Conditions based - * on geometrica objects. - */ -class FEMConditionSetupDialog : public QDialog, private Ui_FEMConditionSetup -{ - Q_OBJECT - -public: - /// Constructor for creating a new FEM condition. - FEMConditionSetupDialog(const std::string &associated_geometry, - const GeoLib::GEOTYPE type, - const std::string &geo_name, - const GeoLib::GeoObject* const geo_object, - bool on_points = false, - QDialog* parent = 0); - - /// Constructor for editing an existing FEM condition. - FEMConditionSetupDialog(const FEMCondition &cond, QDialog* parent = 0); - - /// Constructor for creating DIRECT FEM conditions on MeshNodes. - FEMConditionSetupDialog(const std::string &name, const MeshLib::Mesh* mesh, QDialog* parent = 0); - - ~FEMConditionSetupDialog(void); - -private: - /// Clears the DistributionType-combobox - void clearDisTypeBox(); - /// Sets layout of the dialog according to properties of the object - void setupDialog(); - /// switches the input widget from lineEdit to PushButton (if true) and vice versa (if false) - void setValueInputWidget(bool is_button); - /// Inserts existing values if an existing FEMCondition is being edited - void setValuesFromCond(); - - FEMCondition _cond; - bool _set_on_points; - QComboBox* _combobox; //needed for on_points & linear conds - QPushButton* directButton; // needed for direct conditions - const MeshLib::Mesh* _mesh; // needed for direct conditions - StrictDoubleValidator* _first_value_validator; - -private slots: - /// Instructions if the OK-Button has been pressed. - void accept(); - - /// Instructions if the Cancel-Button has been pressed. - void reject(); - - void on_condTypeBox_currentIndexChanged(int index); - - void on_disTypeBox_currentIndexChanged(int index); - - void directButton_pressed(); - - void addDisValues(std::vector< std::pair<std::size_t,double> > direct_values); - - void copyCondOnPoints(); - - FEMCondition* typeCast(const FEMCondition &cond); - -signals: - void createFEMCondition(std::vector<FEMCondition*>); - -}; - -#endif //FEMCONDITIONSETUPDIALOG_H diff --git a/Gui/DataView/GeoTreeView.cpp b/Gui/DataView/GeoTreeView.cpp index 8c0e28ca33ca15a3ae8e54f2af1d216363d43769..e411499158dda62851d519701c40c181f5144ed2 100644 --- a/Gui/DataView/GeoTreeView.cpp +++ b/Gui/DataView/GeoTreeView.cpp @@ -146,7 +146,7 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) if (parent != NULL) { QMenu* cond_menu = new QMenu("Set FEM Condition"); - menu.addMenu(cond_menu); + //menu.addMenu(cond_menu); QAction* addCondAction = cond_menu->addAction("On object..."); QAction* addCondPointAction = cond_menu->addAction("On all points..."); QAction* addNameAction = menu.addAction("Set name..."); @@ -166,13 +166,13 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) { //QAction* saveAction = menu.addAction("Save geometry..."); QAction* mapAction = menu.addAction("Map geometry..."); - QAction* addCNDAction = menu.addAction("Load FEM Conditions..."); + //QAction* addCNDAction = menu.addAction("Load FEM Conditions..."); //QAction* saveCondAction = menu.addAction("Save FEM conditions..."); menu.addSeparator(); //QAction* removeAction = menu.addAction("Remove geometry"); //connect(saveAction, SIGNAL(triggered()), this, SLOT(writeToFile())); connect(mapAction, SIGNAL(triggered()), this, SLOT(mapGeometry())); - connect(addCNDAction, SIGNAL(triggered()), this, SLOT(loadFEMConditions())); + //connect(addCNDAction, SIGNAL(triggered()), this, SLOT(loadFEMConditions())); //connect(saveCondAction, SIGNAL(triggered()), this, SLOT(saveFEMConditions())); //connect(removeAction, SIGNAL(triggered()), this, SLOT(removeList())); } diff --git a/Gui/DataView/MeshElementRemovalDialog.h b/Gui/DataView/MeshElementRemovalDialog.h index 6f2a77e8f30f587f9212872d52af6355ac62c0ae..bf0a2c21b9104b195ce7cbb60a7f67d6b64300c2 100644 --- a/Gui/DataView/MeshElementRemovalDialog.h +++ b/Gui/DataView/MeshElementRemovalDialog.h @@ -18,7 +18,7 @@ #include "ui_MeshElementRemoval.h" #include <QDialog> -#include "ProjectData.h" +#include "Applications/ProjectData.h" class Node; diff --git a/Gui/DataView/MeshValueEditDialog.h b/Gui/DataView/MeshValueEditDialog.h index 2cb3f8d7660c24b06fc7ffa7f795751630095c11..7fca9c02e40bdba95b950389db173fd568c1fe11 100644 --- a/Gui/DataView/MeshValueEditDialog.h +++ b/Gui/DataView/MeshValueEditDialog.h @@ -16,7 +16,6 @@ #define MESHVALUEEDITDIALOG_H #include "ui_MeshValueEdit.h" -#include "FEMCondition.h" #include <QDialog> diff --git a/Gui/DataView/ModellingTabWidget.cpp b/Gui/DataView/ModellingTabWidget.cpp index 7e8f8082f7997ff4f4ec5b43326738a0a54b0867..a5f09974b03c3addc06737ae2fd7548077277ae8 100644 --- a/Gui/DataView/ModellingTabWidget.cpp +++ b/Gui/DataView/ModellingTabWidget.cpp @@ -13,7 +13,7 @@ */ // ** INCLUDES ** -#include "ProcessModel.h" +//#include "ProcessModel.h" #include "ModellingTabWidget.h" ModellingTabWidget::ModellingTabWidget( QWidget* parent /*= 0*/ ) @@ -22,12 +22,4 @@ ModellingTabWidget::ModellingTabWidget( QWidget* parent /*= 0*/ ) setupUi(this); } -void ModellingTabWidget::on_addProcessButton_pressed() -{ - emit requestNewProcess(); -} -void ModellingTabWidget::on_deleteAllButton_pressed() -{ - static_cast<ProcessModel*>(this->treeView->model())->removeAllProcesses(); -} diff --git a/Gui/DataView/ModellingTabWidget.h b/Gui/DataView/ModellingTabWidget.h index 70369d41ae93938df89abcfeac06bcc48129b565..558814ea0c3d8cc2595163197f601bc55c182d85 100644 --- a/Gui/DataView/ModellingTabWidget.h +++ b/Gui/DataView/ModellingTabWidget.h @@ -29,11 +29,8 @@ public: ModellingTabWidget(QWidget* parent = 0); private slots: - void on_addProcessButton_pressed(); - void on_deleteAllButton_pressed(); signals: - void requestNewProcess(); }; #endif // MODELLINGTABWIDGET_H diff --git a/Gui/DataView/ModellingTabWidgetBase.ui b/Gui/DataView/ModellingTabWidgetBase.ui index d5ede9a4f068c67071fa36ad29cd9d0a27b778e0..eeb74ac188175604c153c54f3658750657d70ed3 100644 --- a/Gui/DataView/ModellingTabWidgetBase.ui +++ b/Gui/DataView/ModellingTabWidgetBase.ui @@ -18,7 +18,7 @@ <number>2</number> </property> <item> - <widget class="ProcessView" name="treeView"/> + <widget class="QTreeView" name="treeView"/> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -40,13 +40,6 @@ </item> </layout> </widget> - <customwidgets> - <customwidget> - <class>ProcessView</class> - <extends>QTreeView</extends> - <header>ProcessView.h</header> - </customwidget> - </customwidgets> <resources/> <connections/> </ui> diff --git a/Gui/DataView/MshModel.h b/Gui/DataView/MshModel.h index d07d3215b14c428d38ed5a444ac96260ff3a55c5..d0fcd7360788eac4db3f92f1ccff058dce60b172 100644 --- a/Gui/DataView/MshModel.h +++ b/Gui/DataView/MshModel.h @@ -16,7 +16,7 @@ #define MSHMODEL_H // ** INCLUDES ** -#include "ProjectData.h" +#include "Applications/ProjectData.h" #include "TreeModel.h" namespace MeshLib { diff --git a/Gui/DataView/MshView.cpp b/Gui/DataView/MshView.cpp index 80d5fa29ec44953c3f8e8cb6a98aa840cda7ad8c..c7f512a66ebc966acf804c093352b916d18e20f2 100644 --- a/Gui/DataView/MshView.cpp +++ b/Gui/DataView/MshView.cpp @@ -138,7 +138,7 @@ void MshView::contextMenuEvent( QContextMenuEvent* event ) } menu.addSeparator(); - menu.addMenu(&direct_cond_menu); + //menu.addMenu(&direct_cond_menu); QAction* addDirectAction = direct_cond_menu.addAction("Add..."); QAction* loadDirectAction = direct_cond_menu.addAction("Load..."); //menu.addSeparator(); diff --git a/Gui/DataView/NewProcessDialog.cpp b/Gui/DataView/NewProcessDialog.cpp deleted file mode 100644 index 787aa13bc05a227e408a05228f68279a2b8863c4..0000000000000000000000000000000000000000 --- a/Gui/DataView/NewProcessDialog.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-17 - * \brief Implementation of the NewProcessDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "NewProcessDialog.h" -#include "FEMEnums.h" -#include "ProcessInfo.h" - - -NewProcessDialog::NewProcessDialog(QDialog* parent) -: QDialog(parent) -{ - setupUi(this); - setupDialog(); -} - -void NewProcessDialog::setupDialog() -{ - const std::list<std::string> process_names = FiniteElement::getAllProcessNames(); - for (std::list<std::string>::const_iterator it = process_names.begin(); it != process_names.end(); ++it) - this->processTypeBox->addItem(QString::fromStdString(*it)); - - const std::list<std::string> pv_names = FiniteElement::getAllPrimaryVariableNames(); - for (std::list<std::string>::const_iterator it = pv_names.begin(); it != pv_names.end(); ++it) - this->pvTypeBox->addItem(QString::fromStdString(*it)); -} - -void NewProcessDialog::accept() -{ - ProcessInfo* info = new ProcessInfo(); - info->setProcessType(static_cast<FiniteElement::ProcessType>(this->processTypeBox->currentIndex() + 1)); - info->setProcessPrimaryVariable(static_cast<FiniteElement::PrimaryVariable>(this->pvTypeBox->currentIndex() + 1)); - - emit addProcess(info); - this->done(QDialog::Accepted); -} - -void NewProcessDialog::reject() -{ - this->done(QDialog::Rejected); -} diff --git a/Gui/DataView/NewProcessDialog.h b/Gui/DataView/NewProcessDialog.h deleted file mode 100644 index 4493b5f2730c3e479c0d602c5703a385a58a4159..0000000000000000000000000000000000000000 --- a/Gui/DataView/NewProcessDialog.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-17 - * \brief Definition of the NewProcessDialog class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef NEWPROCESSDIALOG_H -#define NEWPROCESSDIALOG_H - -#include <QDialog> - -#include "ui_NewProcess.h" - -class ProcessInfo; - -/** - * \brief A dialog window for adding a new process in GUI - */ -class NewProcessDialog : public QDialog, private Ui_NewProcess -{ - Q_OBJECT - -public: - /// Constructor for creating a new FEM condition. - NewProcessDialog(QDialog* parent = 0); - - ~NewProcessDialog(void) {}; - -private: - void setupDialog(); - -private slots: - /// Instructions if the OK-Button has been pressed. - void accept(); - - /// Instructions if the Cancel-Button has been pressed. - void reject(); - -signals: - void addProcess(ProcessInfo*); - -}; - -#endif //NEWPROCESSDIALOG_H diff --git a/Gui/DataView/ProcessItem.h b/Gui/DataView/ProcessItem.h deleted file mode 100644 index b6ec4d1bc150d393af350c5f166ec12769f548c5..0000000000000000000000000000000000000000 --- a/Gui/DataView/ProcessItem.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-11-22 - * \brief Definition of the ProcessItem class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROCESSITEM_H -#define PROCESSITEM_H - -#include "TreeItem.h" -#include "ProcessInfo.h" - -/** - * \brief A TreeItem representing process information. - * \sa TreeItem - */ -class ProcessItem : public TreeItem -{ -public: - /// Constructor - ProcessItem(const QList<QVariant> &data, TreeItem* parent, const ProcessInfo* pcs) - : TreeItem(data, parent), _item(pcs) - { - } - - ~ProcessItem() {} - - /// Returns the Process Information associated with the item. - const ProcessInfo* getItem() { return _item; } - -private: - const ProcessInfo* _item; -}; - -#endif //PROCESSITEM_H diff --git a/Gui/DataView/ProcessModel.cpp b/Gui/DataView/ProcessModel.cpp deleted file mode 100644 index aade42b29133ef48cb3b2f0b41d590d241163cd6..0000000000000000000000000000000000000000 --- a/Gui/DataView/ProcessModel.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-10-18 - * \brief Implementation of the ProcessModel class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "ProcessModel.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -// ** INCLUDES ** -#include "ProcessItem.h" -#include "CondObjectListItem.h" -#include "CondItem.h" -#include "ProcessItem.h" -#include "FEMCondition.h" -#include "GEOObjects.h" -#include "GeoObject.h" -#include "GeoType.h" -#include "FEMEnums.h" - -#include <QFileInfo> -#include <vtkPolyDataAlgorithm.h> - -ProcessModel::ProcessModel(ProjectData &project, QObject* parent /*= 0*/) : - TreeModel(parent), _project(project) -{ - QList<QVariant> rootData; - delete _rootItem; - rootData << "Name" << "Value" << "" << "" << ""; - _rootItem = new TreeItem(rootData, nullptr); -} - -ProcessModel::~ProcessModel() -{ -} - -int ProcessModel::columnCount(const QModelIndex &parent /*= QModelIndex()*/) const -{ - Q_UNUSED(parent) - - return 2; -} - -void ProcessModel::addConditionItem(FEMCondition* c) -{ - ProcessItem* processParent = this->getProcessParent(c->getProcessType()); - if (processParent == nullptr) - { - ProcessInfo* pcs = new ProcessInfo(c->getProcessType(), - c->getProcessPrimaryVariable()/* TODO6, nullptr*/); - processParent = this->addProcess(pcs); - } - - CondObjectListItem* condParent = this->getCondParent(processParent, c->getCondType()); - if (condParent == nullptr) - condParent = this->createCondParent(processParent, c); - else - condParent->addCondition(c); - - QList<QVariant> condData; - condData << QString::fromStdString(c->getGeoName()) - << QString::fromStdString(c->getGeomTypeAsString()); - CondItem* condItem = new CondItem(condData, condParent, c); - condParent->appendChild(condItem); - // add information on primary variable - QList<QVariant> pvData; - pvData << QString::fromStdString(convertPrimaryVariableToString(c->getProcessPrimaryVariable())); - TreeItem* pvInfo = new TreeItem(pvData, condItem); - // add distribution information - QList<QVariant> disData; - disData << QString::fromStdString(convertDisTypeToString(c->getProcessDistributionType())); - std::vector<size_t> dis_nodes = c->getDisNodes(); - std::vector<double> dis_values = c->getDisValues(); - TreeItem* disInfo; - if (c->getProcessDistributionType() == FiniteElement::CONSTANT || - c->getProcessDistributionType() == FiniteElement::CONSTANT_NEUMANN || - c->getProcessDistributionType() == FiniteElement::NODESCONSTANT) - { - disData << dis_values[0]; - disInfo = new TreeItem(disData, condItem); - } - else - { - size_t nVals = dis_values.size(); - disData << static_cast<int>(nVals); - disInfo = new TreeItem(disData, condItem); - for (size_t i = 0; i < nVals; i++) - { - QList<QVariant> linData; - linData << static_cast<int>(dis_nodes[i]) << dis_values[i]; - TreeItem* linInfo = new TreeItem(linData, disInfo); - disInfo->appendChild(linInfo); - } - } - - //condItem->appendChild(pcsInfo); - condItem->appendChild(pvInfo); - condItem->appendChild(disInfo); - - reset(); -} - -void ProcessModel::addCondition(FEMCondition* condition) -{ - // HACK: direct source terms are not domain conditions but they also don't contain geo-object-names - bool is_domain (false); - if (condition->getProcessDistributionType() == FiniteElement::NODESCONSTANT || - condition->getProcessDistributionType() == FiniteElement::DIRECT) - is_domain = true; - - const GeoLib::GeoObject* object = condition->getGeoObj(); - if (object == nullptr) - { - object = _project.getGEOObjects()->getGeoObject(condition->getAssociatedGeometryName(), - condition->getGeomType(), condition->getGeoName()); - condition->setGeoObj(object); - } - if (object || is_domain) - { - this->addConditionItem(condition); - } - else - ERR("ProcessModel::addConditions(): Specified geometrical object \"%s\" not found in associated geometry.", - condition->getGeoName().c_str()); -} - -void ProcessModel::addConditions(std::vector<FEMCondition*> &conditions) -{ - for (size_t i = 0; i < conditions.size(); i++) - this->addCondition(conditions[i]); -} - -ProcessItem* ProcessModel::addProcess(ProcessInfo *pcs) -{ - if (this->getProcessParent(pcs->getProcessType()) == nullptr) - { - this->_project.addProcess(pcs); - QList<QVariant> processData; - processData - << QVariant( - QString::fromStdString( - FiniteElement::convertProcessTypeToString(pcs->getProcessType()))) - << ""; - ProcessItem* process = new ProcessItem(processData, _rootItem, pcs); - _rootItem->appendChild(process); - reset(); - return process; - } - else - { - WARN("ProcessModel::addProcess(): %s already exists.", - FiniteElement::convertProcessTypeToString(pcs->getProcessType()).c_str()); - return nullptr; - } -} - -const FEMCondition* ProcessModel::getCondition(const FiniteElement::ProcessType pcs_type, const std::string &geo_name, const FEMCondition::CondType cond_type, const GeoLib::GEOTYPE geo_type, const std::string &cond_name) const -{ - Q_UNUSED(geo_name); - ProcessItem const*const pcs_item (this->getProcessParent(pcs_type)); - if (!pcs_item) - return nullptr; - CondObjectListItem const*const cnd_list = getCondParent(pcs_item, cond_type); - if (!cnd_list) - return nullptr; - for (int i = 0; i < cnd_list->childCount(); i++) - { - CondItem* item = static_cast<CondItem*>(cnd_list->child(i)); - if ((item->data(0).toString().toStdString().compare(cond_name) == 0) && - (item->data(1).toString().toStdString().compare(GeoLib::convertGeoTypeToString(geo_type)) == 0)) - return item->getItem(); - } - return nullptr; -} - -void ProcessModel::removeConditions(const FiniteElement::ProcessType pcs_type, - const std::string &geometry_name, const FEMCondition::CondType cond_type) -{ - _project.removeConditions(pcs_type, geometry_name, cond_type); - - while (_rootItem->childCount() > 0) - { - ProcessItem* pcs = static_cast<ProcessItem*>(_rootItem->child(0)); - for (int j = 0; j < pcs->childCount(); j++) - emit conditionsRemoved(this, pcs->getItem()->getProcessType(), - (static_cast<CondObjectListItem*>(pcs->child(j)))->getType()); - - _rootItem->removeChildren(0, 1); - } - - const std::vector<FEMCondition*> conds = _project.getConditions(FiniteElement::INVALID_PROCESS, - "", FEMCondition::UNSPECIFIED); - if (!conds.empty()) - { - size_t nConds(conds.size()); - for (size_t i = 0; i < nConds; i++) - this->addConditionItem(conds[i]); - } - reset(); -} - -void ProcessModel::removeProcess(const FiniteElement::ProcessType type) -{ - this->removeConditions(type, "", FEMCondition::UNSPECIFIED); - - const ProcessItem* processParent = this->getProcessParent(type); - if (processParent) - { - this->_project.removeProcess(type); - removeRows(processParent->row(), 1, QModelIndex()); - } - reset(); -} - -void ProcessModel::removeAllProcesses() -{ - int nProcesses = _rootItem->childCount(); - for (int i = 0; i < nProcesses; i++) - { - ProcessItem* item = static_cast<ProcessItem*>(_rootItem->child(i)); - removeProcess(item->getItem()->getProcessType()); - } -} - -int ProcessModel::getGEOIndex(const std::string &geo_name, GeoLib::GEOTYPE type, - const std::string &obj_name) const -{ - bool exists(false); - size_t idx(0); - if (type == GeoLib::GEOTYPE::POINT) - exists = this->_project.getGEOObjects()->getPointVecObj(geo_name)->getElementIDByName( - obj_name, idx); - else if (type == GeoLib::GEOTYPE::POLYLINE) - exists = this->_project.getGEOObjects()->getPolylineVecObj(geo_name)->getElementIDByName( - obj_name, idx); - else if (type == GeoLib::GEOTYPE::SURFACE) - exists = this->_project.getGEOObjects()->getSurfaceVecObj(geo_name)->getElementIDByName( - obj_name, idx); - - if (exists) - return static_cast<int>(idx); - return -1; -} - -ProcessItem* ProcessModel::getProcessParent(const FiniteElement::ProcessType type) const -{ - int nLists = _rootItem->childCount(); - for (int i = 0; i < nLists; i++) - if (static_cast<ProcessItem*>(_rootItem->child(i))->getItem()->getProcessType() == type) - return static_cast<ProcessItem*>(_rootItem->child(i)); - return nullptr; -} - -CondObjectListItem* ProcessModel::getCondParent(TreeItem const*const parent, const FEMCondition::CondType type) const -{ - int nLists = parent->childCount(); - for (int i = 0; i < nLists; i++) - if (dynamic_cast<CondObjectListItem*>(parent->child(i))->getType() == type) - return dynamic_cast<CondObjectListItem*>(parent->child(i)); - return nullptr; -} - -CondObjectListItem* ProcessModel::createCondParent(ProcessItem* parent, FEMCondition* cond) -{ - QString condType(QString::fromStdString(FEMCondition::condTypeToString(cond->getCondType()))); - QList<QVariant> condData; - condData << condType << ""; - - const std::vector<GeoLib::Point*>* pnts = _project.getGEOObjects()->getPointVec( - cond->getAssociatedGeometryName()); - if (pnts) - { - CondObjectListItem* cond_list = new CondObjectListItem(condData, parent, cond, pnts); - parent->appendChild(cond_list); - emit conditionAdded(this, parent->getItem()->getProcessType(), cond->getCondType()); - return cond_list; - } - - return nullptr; -} - -vtkPolyDataAlgorithm* ProcessModel::vtkSource(const FiniteElement::ProcessType pcs_type, - const FEMCondition::CondType cond_type) -{ - ProcessItem* processParent = this->getProcessParent(pcs_type); - if (processParent) - { - CondObjectListItem* condParent = this->getCondParent(processParent, cond_type); - if (condParent) - return condParent->vtkSource(); - } - return nullptr; -} - -void ProcessModel::replaceCondition(const QModelIndex &idx, FEMCondition* condition) -{ - // remove old condition - this->getItem(idx)->parentItem()->removeChildren(this->getItem(idx)->row(), 1); - //add new condition - this->addCondition(condition); -} - -void ProcessModel::updateModel() -{ - const std::vector<FEMCondition*> cnd_vec = _project.getConditions(); - for (auto it(cnd_vec.cbegin()); it != cnd_vec.cend(); ++it) - // if Condition is not yet added to GUI, do it now - if (!this->getCondition((*it)->getProcessType(), (*it)->getAssociatedGeometryName(), (*it)->getCondType(), (*it)->getGeomType(), (*it)->getGeoName())) - addConditionItem(*it); -} diff --git a/Gui/DataView/ProcessModel.h b/Gui/DataView/ProcessModel.h deleted file mode 100644 index d105177bc1bf9cb245b82c737b211d96f4f9c32b..0000000000000000000000000000000000000000 --- a/Gui/DataView/ProcessModel.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-10-18 - * \brief Definition of the ProcessModel class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROCESSMODEL_H -#define PROCESSMODEL_H - -// ** INCLUDES ** -#include "ProjectData.h" -#include "TreeModel.h" - -class FEMCondition; -class ProcessItem; -class CondObjectListItem; -class vtkPolyDataAlgorithm; - -namespace GeoLib -{ -class GeoObject; -} - -/** - * \brief A model implementing a tree structure for process-relevant information such as - * process types, FEM-Conditions (BCs, ICs, STs), etc. as a double-linked list. - * \sa TreeModel, ProcessView, TreeItem, CondObjectListItem - */ -class ProcessModel : public TreeModel -{ - Q_OBJECT - -public: - ProcessModel(ProjectData &project, QObject* parent = 0); - ~ProcessModel(); - - int columnCount(const QModelIndex& parent = QModelIndex()) const; - /// Returns the vtk source object for the specified subtree of a process with the given name. - vtkPolyDataAlgorithm* vtkSource(const FiniteElement::ProcessType pcs_type, const FEMCondition::CondType cond_type); - -public slots: - /// Adds a vector of FEM Conditions to the model. Objects in the vector can consist of BCs, ICs or STs in any combination and sequence. - void addConditions(std::vector<FEMCondition*> &conditions); - - /// Adds a single FEM Conditions to the model - void addCondition(FEMCondition* condition); - - /// Adds a process to the model - ProcessItem* addProcess(ProcessInfo* pcs); - - /// Returns the FEM Condition set on a GeoObject with the given name and type from a certain geometry. - const FEMCondition* getCondition(const FiniteElement::ProcessType pcs_type, const std::string &geo_name, const FEMCondition::CondType cond_type, const GeoLib::GEOTYPE geo_type, const std::string &cond_name) const; - - /// Removes FEMConditions from the the model. Conditions can be specified by process type, geometry name or condition type or a combination of the three. - void removeConditions(const FiniteElement::ProcessType pcs_type, const std::string &geometry_name, const FEMCondition::CondType cond_type); - - /// Removes a process from the model - void removeProcess(const FiniteElement::ProcessType type); - - /// Removes all processes from the model - void removeAllProcesses(); - - /// Remove the given TreeItem and replace it with another condition (this is used for editing FEMConditions) - void replaceCondition(const QModelIndex &idx, FEMCondition* condition); - - /// Updates the model based on the ProjectData-object - void updateModel(); - -private: - /// Adds a new FEM condition to the condition tree model. - void addConditionItem(FEMCondition* condition); - - /// Removes the FEM condition with the given index. - //bool removeConditionItem(const QModelIndex &idx); - - /// Creates the TreeItem for one of the condition subtrees. - CondObjectListItem* createCondParent(ProcessItem* parent, FEMCondition* cond); - - /// Returns the subtree-item for a given type of condtion. - CondObjectListItem* getCondParent(TreeItem const*const parent, const FEMCondition::CondType type) const; - - /// Returns the subtree item for a process with the given name. If create_item is true, this item will be created if it doesn't exist yet. - ProcessItem* getProcessParent(const FiniteElement::ProcessType type) const; - - /// Returns the index of a geometric item of the given name and type for the associated geometry. - int getGEOIndex(const std::string &geo_name, - GeoLib::GEOTYPE type, - const std::string &obj_name) const; - - ProjectData& _project; - -signals: - void conditionAdded(ProcessModel*, const FiniteElement::ProcessType, const FEMCondition::CondType); - void conditionsRemoved(ProcessModel*, const FiniteElement::ProcessType, const FEMCondition::CondType); -}; - -#endif // PROCESSMODEL_H diff --git a/Gui/DataView/ProcessView.cpp b/Gui/DataView/ProcessView.cpp deleted file mode 100644 index 450be7e46c372d6615ce7f73012378262a2185ff..0000000000000000000000000000000000000000 --- a/Gui/DataView/ProcessView.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-12-13 - * \brief Implementation of the ProcessView class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include <QMenu> -#include <QFileDialog> - -#include "ProcessItem.h" -#include "CondObjectListItem.h" -#include "CondItem.h" -#include "ProcessModel.h" -#include "ProcessView.h" -#include "FEMConditionSetupDialog.h" -#include "SelectMeshDialog.h" - -ProcessView::ProcessView(QWidget* parent) : QTreeView(parent) -{ -} - -void ProcessView::updateView() -{ - setAlternatingRowColors(true); - resizeColumnToContents(0); - setColumnWidth(1,50); - setColumnWidth(2,50); -} - -void ProcessView::on_Clicked(QModelIndex idx) -{ - qDebug("%d, %d",idx.parent().row(), idx.row()); -} - -void ProcessView::selectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) -{ - emit itemSelectionChanged(selected, deselected); - QTreeView::selectionChanged(selected, deselected); -} - -void ProcessView::contextMenuEvent( QContextMenuEvent* event ) -{ - Q_UNUSED(event); - - const QModelIndex idx(this->selectionModel()->currentIndex()); - QMenu menu; - - if (this->isProcessItem(idx)) - { - QAction* saveCondAction = menu.addAction("Save FEM Conditions..."); - QAction* removePCSAction = menu.addAction("Remove process"); - connect(saveCondAction, SIGNAL(triggered()), this, SLOT(saveConditions())); - connect(removePCSAction, SIGNAL(triggered()), this, SLOT(removeProcess())); - } - else if (this->isListItem(idx)) - { - QAction* removeCondAction = menu.addAction("Remove conditions"); - connect(removeCondAction, SIGNAL(triggered()), this, SLOT(removeCondition())); - } - else if (this->isConditionItem(idx)) - { - - QAction* editCondAction = menu.addAction("Edit condition"); - // check if condition on mesh, if so it is not editable - if (GeoLib::convertGeoType(static_cast<ProcessModel*>(this->model())->getItem(idx)->data(1).toString().toStdString()) != GeoLib::GEOTYPE::INVALID) - connect(editCondAction, SIGNAL(triggered()), this, SLOT(editCondition())); - else - editCondAction->setEnabled(false); - } - - menu.exec(event->globalPos()); -} - -void ProcessView::removeCondition() -{ - CondObjectListItem* item = dynamic_cast<CondObjectListItem*>(static_cast<ProcessModel*>(this->model())->getItem(this->selectionModel()->currentIndex())); - - if (item) - { - const FiniteElement::ProcessType pcs_type = static_cast<ProcessItem*>(item->parentItem())->getItem()->getProcessType(); - const FEMCondition::CondType cond_type = item->getType(); - emit conditionsRemoved(pcs_type, "", cond_type); - } -} - -void ProcessView::editCondition() -{ - CondItem* item = dynamic_cast<CondItem*>(static_cast<ProcessModel*>(this->model())->getItem(this->selectionModel()->currentIndex())); - - if (item) - { - FEMConditionSetupDialog dlg(*(item->getItem())); - connect(&dlg, SIGNAL(createFEMCondition(std::vector<FEMCondition*>)), this, SLOT(replaceCondition(std::vector<FEMCondition*>))); - dlg.exec(); - } -} - -void ProcessView::replaceCondition(std::vector<FEMCondition*> conditions) -{ - static_cast<ProcessModel*>(this->model())->replaceCondition(this->selectionModel()->currentIndex(), conditions[0]); - this->reset(); -} - -void ProcessView::saveConditions() -{ - emit saveConditionsRequested(); -} - -void ProcessView::removeProcess() -{ - ProcessItem* item = dynamic_cast<ProcessItem*>(static_cast<ProcessModel*>(this->model())->getItem(this->selectionModel()->currentIndex())); - - if (item) - { - const FiniteElement::ProcessType pcs_type = item->getItem()->getProcessType(); - emit processRemoved(pcs_type); - } -} - -bool ProcessView::isProcessItem(const QModelIndex &idx) const -{ - ProcessItem* pcs_item = dynamic_cast<ProcessItem*>(static_cast<ProcessModel*>(this->model())->getItem(idx)); - if (pcs_item) return true; - return false; -} - -bool ProcessView::isListItem(const QModelIndex &idx) const -{ - CondObjectListItem* cond_item = dynamic_cast<CondObjectListItem*>(static_cast<ProcessModel*>(this->model())->getItem(idx)); - if (cond_item) return true; - return false; -} - -bool ProcessView::isConditionItem(const QModelIndex &idx) const -{ - CondObjectListItem* cond_item = dynamic_cast<CondObjectListItem*>(static_cast<ProcessModel*>(this->model())->getItem(idx.parent())); - if (cond_item) return true; - return false; -} diff --git a/Gui/DataView/ProcessView.h b/Gui/DataView/ProcessView.h deleted file mode 100644 index 573d3507cbf485d6379fca72289dcbbe88f5ca59..0000000000000000000000000000000000000000 --- a/Gui/DataView/ProcessView.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-12-13 - * \brief Definition of the ProcessView class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROCESSVIEW_H -#define PROCESSVIEW_H - -#include <QContextMenuEvent> -#include <QTreeView> - -#include "FEMCondition.h" - -class ConditionModel; - -/** - * \brief A view for FEM-Conditions (Initial- & Boundary Conditions / Source Terms) with a number of additional - * information such as Process Type, Distribution, etc. - * \sa ConditionModel, CondItem - */ -class ProcessView : public QTreeView -{ - Q_OBJECT - -public: - /// Constructor - ProcessView(QWidget* parent = 0); - - /// Update the view to visualise changes made to the underlying data - void updateView(); - -protected slots: - /// Instructions if the selection of items in the view has changed. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); - -private: - /// Actions to be taken after a right mouse click is performed in the station view. - void contextMenuEvent( QContextMenuEvent* e ); - bool isProcessItem(const QModelIndex &idx) const; - bool isListItem(const QModelIndex &idx) const; - bool isConditionItem(const QModelIndex &idx) const; - -private slots: - void on_Clicked(QModelIndex idx); - void editCondition(); - void removeCondition(); - void removeProcess(); - void replaceCondition(std::vector<FEMCondition*> conditions); - void saveConditions(); - -signals: - void conditionsRemoved(const FiniteElement::ProcessType, const std::string&, const FEMCondition::CondType); - void itemSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); - void processRemoved(const FiniteElement::ProcessType); - void saveConditionsRequested(); -}; - -#endif //PROCESSVIEW_H - diff --git a/Gui/VtkVis/CMakeLists.txt b/Gui/VtkVis/CMakeLists.txt index eaaa3aa07b16ee1677729ce8e18acba1537f5821..df82604fe250532cafbd6a8ac47fc2492bcbaf5e 100644 --- a/Gui/VtkVis/CMakeLists.txt +++ b/Gui/VtkVis/CMakeLists.txt @@ -24,7 +24,6 @@ SET( SOURCES VtkCompositePointToGlyphFilter.cpp VtkCompositeTextureOnSurfaceFilter.cpp VtkCompositeThresholdFilter.cpp - VtkConditionSource.cpp VtkFilterFactory.cpp VtkGeoImageSource.cpp VtkImageDataToLinePolyDataFilter.cpp @@ -82,7 +81,6 @@ SET( HEADERS VtkCompositePointToGlyphFilter.h VtkCompositeTextureOnSurfaceFilter.h VtkCompositeThresholdFilter.h - VtkConditionSource.h VtkFilterFactory.h VtkGeoImageSource.h VtkImageDataToLinePolyDataFilter.h @@ -137,7 +135,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../../MathLib ${CMAKE_CURRENT_SOURCE_DIR}/../../FileIO ${CMAKE_CURRENT_SOURCE_DIR}/../../MeshLib - ${CMAKE_CURRENT_SOURCE_DIR}/../../OGS ${CMAKE_CURRENT_SOURCE_DIR}/../Base ${CMAKE_CURRENT_SOURCE_DIR}/../DataView ${CMAKE_CURRENT_BINARY_DIR}/../DataView diff --git a/Gui/VtkVis/VtkConditionSource.cpp b/Gui/VtkVis/VtkConditionSource.cpp deleted file mode 100644 index 47cd1c10a600e440874e2221a2a437cd55d389bc..0000000000000000000000000000000000000000 --- a/Gui/VtkVis/VtkConditionSource.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-03-02 - * \brief Implementation of the VtkConditionSource class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -// ** INCLUDES ** -// GeoLib -#include "AABB.h" -#include "Color.h" -#include "Polyline.h" -#include "Surface.h" - -#include "FEMCondition.h" -#include "VtkConditionSource.h" - -#include <vtkCellArray.h> -#include <vtkDoubleArray.h> -#include <vtkInformation.h> -#include <vtkInformationVector.h> -#include <vtkObjectFactory.h> -#include <vtkPointData.h> -#include <vtkPoints.h> -#include <vtkPolyData.h> -#include <vtkPolygon.h> -#include <vtkProperty.h> -#include <vtkSmartPointer.h> -#include <vtkStreamingDemandDrivenPipeline.h> - -#include <vtkLookupTable.h> - -vtkStandardNewMacro(VtkConditionSource); -vtkCxxRevisionMacro(VtkConditionSource, "$Revision$"); - -VtkConditionSource::VtkConditionSource() - : _points(NULL), _cond_vec(NULL) -{ - this->SetNumberOfInputPorts(0); - - const GeoLib::Color* c = GeoLib::getRandomColor(); - GetProperties()->SetColor((*c)[0] / 255.0,(*c)[1] / 255.0,(*c)[2] / 255.0); -} - -VtkConditionSource::~VtkConditionSource() -{ -} - -void VtkConditionSource::setData(const std::vector<GeoLib::Point*>* points, - const std::vector<FEMCondition*>* conds) -{ - _removable = false; // From VtkAlgorithmProperties - _points = points; - _cond_vec = conds; -} - -void VtkConditionSource::PrintSelf( ostream& os, vtkIndent indent ) -{ - this->Superclass::PrintSelf(os,indent); - - if (_points->size() == 0) - return; - - os << indent << "== VtkConditionSource ==" << "\n"; -} - -int VtkConditionSource::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) -{ - (void)request; - (void)inputVector; - - if (this->_points->empty() || this->_cond_vec->empty()) - return 0; - - vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New(); - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); - vtkSmartPointer<vtkPolyData> output = - vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); - - vtkSmartPointer<vtkIdTypeArray> distypes = vtkSmartPointer<vtkIdTypeArray>::New(); - distypes->SetNumberOfComponents(1); - distypes->SetName("DisTypes"); - - vtkSmartPointer<vtkDoubleArray> scalars = vtkSmartPointer<vtkDoubleArray>::New(); - scalars->SetNumberOfComponents(1); - scalars->SetName("Scalars"); - //std::map<size_t, size_t> idx_map; - - vtkSmartPointer<vtkCellArray> newVerts = vtkSmartPointer<vtkCellArray>::New(); - vtkSmartPointer<vtkCellArray> newLines = vtkSmartPointer<vtkCellArray>::New(); - vtkSmartPointer<vtkCellArray> newPolys = vtkSmartPointer<vtkCellArray>::New(); - - if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) - return 1; - /* - size_t n_pnts = _points->size(); - double value(-9999); - if (!_cond_vec->empty()) - { - const std::vector<double> dv = (*_cond_vec)[0]->getDisValue(); - value = dv[dv.size()-1]; // get an existing value for the distribution so scaling on point data will be correct during rendering process! - } - - for (size_t i = 0; i < n_pnts; i++) - { - double coords[3] = {(*(*_points)[i])[0], (*(*_points)[i])[1], (*(*_points)[i])[2]}; - newPoints->InsertNextPoint(coords); - distypes->InsertNextValue(0); - scalars->InsertNextValue(value); - } - */ - vtkIdType pnt_id = 0; - size_t nCond = _cond_vec->size(); - for (size_t n = 0; n < nCond; n++) - { - FiniteElement::DistributionType type = (*_cond_vec)[n]->getProcessDistributionType(); - const std::vector<size_t> dis_nodes = (*_cond_vec)[n]->getDisNodes(); - const std::vector<double> dis_values = (*_cond_vec)[n]->getDisValues(); - - vtkIdType dis_type_value(0); - std::map<FiniteElement::DistributionType, vtkIdType>::const_iterator it(_dis_type_map.find(type)); - if (it == _dis_type_map.end()) - { - dis_type_value = static_cast<vtkIdType>(_dis_type_map.size()); - _dis_type_map.insert(std::pair<FiniteElement::DistributionType, size_t>(type, dis_type_value)); - } - else - dis_type_value = it->second; - - if ((*_cond_vec)[n]->getGeomType() == GeoLib::GEOTYPE::POINT) - { - /* - size_t nPoints = _points->size(); - const GeoLib::Point* pnt = - static_cast<const GeoLib::Point*>((*_cond_vec)[n]->getGeoObj()); - int id(-1); - for (size_t i = 0; i < nPoints; i++) - if ((*_points)[i] == pnt) - { - id = static_cast<int>(i); //(this->getIndex(i, newPoints, scalars, idx_map)); - vtkIdType vtk_id = static_cast<vtkIdType>(id); - */ - const GeoLib::Point* pnt = static_cast<const GeoLib::Point*>((*_cond_vec)[n]->getGeoObj()); - newPoints->InsertNextPoint(pnt->getCoords()); - - newVerts->InsertNextCell(1, &pnt_id); - if (type == FiniteElement::CONSTANT || type == FiniteElement::CONSTANT_NEUMANN) - scalars->InsertNextValue(dis_values[0]); - else scalars->InsertNextValue(0); - distypes->InsertNextValue(dis_type_value); - pnt_id++; - /* - break; - } - if (id == -1) - std::cout << - "Error in VtkConditionSource::RequestData() - Point object not found ..." - << std::endl; - */ - } - else if ((*_cond_vec)[n]->getGeomType() == GeoLib::GEOTYPE::POLYLINE) - { - const GeoLib::Polyline* ply = - static_cast<const GeoLib::Polyline*>((*_cond_vec)[n]->getGeoObj()); - const int nPoints = ply->getNumberOfPoints(); - newLines->InsertNextCell(nPoints); - double value (0); - for (int i = 0; i < nPoints; i++) - { - size_t point_index = ply->getPointID(i); - - newPoints->InsertNextPoint((*_points)[point_index]->getCoords()); - newLines->InsertCellPoint(pnt_id); - distypes->InsertNextValue(dis_type_value); - - if (type == FiniteElement::CONSTANT || type == FiniteElement::CONSTANT_NEUMANN) - scalars->InsertNextValue(dis_values[0]); - else if (type == FiniteElement::LINEAR || type == FiniteElement::LINEAR_NEUMANN) - { - for (size_t j = 0; j < dis_values.size(); j++) - { - if (static_cast<int>(dis_nodes[j]) == i) - value = dis_values[j]; - } - scalars->InsertNextValue(value); - } - else - scalars->InsertNextValue(0); - pnt_id++; - } - } - else if ((*_cond_vec)[n]->getGeomType() == GeoLib::GEOTYPE::SURFACE) - { - std::vector<int> point_idx_map(_points->size(), -1); - - const GeoLib::Surface* sfc = - static_cast<const GeoLib::Surface*>((*_cond_vec)[n]->getGeoObj()); - - const size_t nTriangles = sfc->getNTriangles(); - - for (size_t i = 0; i < nTriangles; i++) - { - vtkPolygon* aPolygon = vtkPolygon::New(); - aPolygon->GetPointIds()->SetNumberOfIds(3); - - const GeoLib::Triangle* triangle = (*sfc)[i]; - for (size_t j = 0; j < 3; j++) - { - size_t point_index ((*triangle)[j]); - - if (point_idx_map[point_index] == -1) - { - point_idx_map[point_index] = pnt_id; - newPoints->InsertNextPoint( - (*_points)[point_index]->getCoords()); - aPolygon->GetPointIds()->SetId(j, pnt_id); - distypes->InsertNextValue(dis_type_value); - - if (type == FiniteElement::CONSTANT || type == FiniteElement::CONSTANT_NEUMANN) - scalars->InsertNextValue(dis_values[0]); - else if (type == FiniteElement::LINEAR || type == FiniteElement::LINEAR_NEUMANN) - { - for (size_t k = 0; k < dis_values.size(); k++) - if (static_cast<size_t>(dis_nodes[j]) == point_index) - { - scalars->InsertNextValue(dis_values[j]); - break; - } - } - else scalars->InsertNextValue(0); - pnt_id++; - } - else - aPolygon->GetPointIds()->SetId(j, static_cast<vtkIdType>(point_idx_map[point_index])); - } - newPolys->InsertNextCell(aPolygon); - - aPolygon->Delete(); - } - } - // HACK: this is currently used when applying DIRECT conditions - else if ((*_cond_vec)[n]->getGeomType() == GeoLib::GEOTYPE::INVALID) - { - size_t nValues = dis_values.size(); - for (size_t i = 0; i < nValues; i++) - { - //vtkIdType pid = newPoints->InsertNextPoint((*_points)[dis_nodes[i]]->getData()); - vtkIdType pid = newPoints->InsertNextPoint((*_points)[i]->getCoords()); - newVerts->InsertNextCell(1, &pid); - scalars->InsertNextValue(dis_values[i]); - distypes->InsertNextValue(dis_type_value); - pnt_id++; - } - } - // draw a bounding box in case of of the conditions is "domain" - else if ((*_cond_vec)[n]->getGeomType() == GeoLib::GEOTYPE::GEODOMAIN) - { - GeoLib::AABB<GeoLib::Point> bounding_box (_points->begin(), _points->end()); - std::vector<GeoLib::Point> box; - box.push_back(bounding_box.getMinPoint()); - box.push_back(bounding_box.getMaxPoint()); - - vtkIdType nPoints = newPoints->GetNumberOfPoints(); - //size_t pnt_idx = _points->size(); - - for (size_t i = 0; i < 8; i++) - { - double coords[3] = - {box[i % 2][0], box[(i >> 1) % 2][1], box[i >> 2][2]}; - newPoints->InsertNextPoint(coords); - distypes->InsertNextValue(dis_type_value); - scalars->InsertNextValue(0.0); - //idx_map.insert( std::pair<size_t,size_t>(pnt_idx+i, nPoints+i)); - } - - for (vtkIdType i = 0; i < 4; i++) - { - vtkIdType a[2] = {nPoints + i, nPoints + i + 4}; - vtkIdType b[2] = {nPoints + (i * 2), nPoints + (i * 2 + 1)}; - vtkIdType c[2] = {nPoints + (static_cast<int>(i / 2) * 4 + (i % 2)), nPoints + (static_cast<int>(i / 2) * 4 + (i % 2) + 2)}; - newLines->InsertNextCell(2, &a[0]); - newLines->InsertNextCell(2, &b[0]); - newLines->InsertNextCell(2, &c[0]); - } - } - } - - output->SetPoints(newPoints); - output->GetPointData()->AddArray(distypes); - output->GetPointData()->AddArray(scalars); - output->GetPointData()->SetActiveScalars("Scalars"); - output->SetVerts(newVerts); - output->SetLines(newLines); - output->SetPolys(newPolys); - - return 1; -} - -int VtkConditionSource::RequestInformation( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) -{ - (void)request; - (void)inputVector; - - vtkInformation* outInfo = outputVector->GetInformationObject(0); - outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), -1); - - return 1; -} - -void VtkConditionSource::SetUserProperty( QString name, QVariant value ) -{ - Q_UNUSED(name); - Q_UNUSED(value); -} - -/* - size_t VtkConditionSource::getIndex(size_t idx, vtkSmartPointer<vtkPoints> newPoints, vtkSmartPointer<vtkDoubleArray> scalars, std::map<size_t, size_t> &idx_map) - { - std::map<size_t,size_t>::iterator mapped_index = idx_map.find(idx); - if (mapped_index != idx_map.end()) return mapped_index->second; - - double coords[3] = {(*(*_points)[idx])[0], (*(*_points)[idx])[1], (*(*_points)[idx])[2]}; - newPoints->InsertNextPoint(coords); - scalars->InsertNextValue(0.0); - size_t new_idx = idx_map.size(); - idx_map.insert( std::pair<size_t,size_t>(idx, new_idx) ); - std::cout << idx << ", " << new_idx << std::endl; - return new_idx; - } - */ diff --git a/Gui/VtkVis/VtkConditionSource.h b/Gui/VtkVis/VtkConditionSource.h deleted file mode 100644 index 9049176e6ca25b6a8da6d35ecb58f836d00da83b..0000000000000000000000000000000000000000 --- a/Gui/VtkVis/VtkConditionSource.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-03-02 - * \brief Definition of the VtkConditionSource class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef VTKCONDITIONSOURCE_H -#define VTKCONDITIONSOURCE_H - -// ** INCLUDES ** -#include "VtkAlgorithmProperties.h" -#include <vtkPolyDataAlgorithm.h> - -// GeoLib -#include "Point.h" - -//#include <vtkSmartPointer.h> - -class FEMCondition; -//class vtkPoints; -//class vtkDoubleArray; - -/** - * \brief VtkConditionSource is a VTK source object for the visualization - * of FEM conditions. As a vtkPolyDataAlgorithm it outputs polygonal data. - */ -class VtkConditionSource : public vtkPolyDataAlgorithm, public VtkAlgorithmProperties -{ -public: - /// Create new objects with New() because of VTKs object reference counting. - static VtkConditionSource* New(); - - vtkTypeRevisionMacro(VtkConditionSource,vtkPolyDataAlgorithm); - - /// Sets the FEMCondition that need to be visualised. The geometry points array is needed because polylines and surfaces are linked to this data. - void setData(const std::vector<GeoLib::Point*>* points, - const std::vector<FEMCondition*>* conds); - - /// Prints its data on a stream. - void PrintSelf(ostream& os, vtkIndent indent); - - virtual void SetUserProperty(QString name, QVariant value); - -protected: - VtkConditionSource(); - ~VtkConditionSource(); - - /// Computes the polygonal data object. - int RequestData(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector); - - int RequestInformation(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector); - -private: - //std::size_t getIndex(std::size_t idx, vtkSmartPointer<vtkPoints> newPoints, vtkSmartPointer<vtkDoubleArray> scalars, std::map<std::size_t, std::size_t> &idx_map); - - const std::vector<GeoLib::Point*>* _points; - const std::vector<FEMCondition*>* _cond_vec; - std::map<FiniteElement::DistributionType, vtkIdType> _dis_type_map; -}; - -#endif // VTKCONDITIONSOURCE_H diff --git a/Gui/VtkVis/VtkVisPipeline.cpp b/Gui/VtkVis/VtkVisPipeline.cpp index 72810eb0d3a63c873142c7c664d736d03ac6e765..8326c171b2e5831035a74377af435fefd0d529a6 100644 --- a/Gui/VtkVis/VtkVisPipeline.cpp +++ b/Gui/VtkVis/VtkVisPipeline.cpp @@ -22,7 +22,6 @@ #include "InterpolationAlgorithms/LinearIntervalInterpolation.h" //#include "Model.h" -#include "ProcessModel.h" #include "GeoTreeModel.h" #include "MeshQuality/AngleSkewMetric.h" #include "MeshQuality/AreaMetric.h" @@ -279,11 +278,6 @@ void VtkVisPipeline::addPipelineItem(StationTreeModel* model, const std::string addPipelineItem(model->vtkSource(name)); } -void VtkVisPipeline::addPipelineItem(ProcessModel* model, const FiniteElement::ProcessType pcs_type, const FEMCondition::CondType cond_type) -{ - addPipelineItem(model->vtkSource(pcs_type, cond_type)); -} - void VtkVisPipeline::addPipelineItem(MshModel* model, const QModelIndex &idx) { addPipelineItem(static_cast<MshItem*>(model->getItem(idx))->vtkSource()); @@ -372,19 +366,6 @@ void VtkVisPipeline::removeSourceItem(GeoTreeModel* model, } } -void VtkVisPipeline::removeSourceItem(ProcessModel* model, const FiniteElement::ProcessType pcs_type, const FEMCondition::CondType cond_type) -{ - for (int i = 0; i < _rootItem->childCount(); i++) - { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); - if (item->algorithm() == model->vtkSource(pcs_type, cond_type)) - { - removePipelineItem(index(i, 0)); - return; - } - } -} - void VtkVisPipeline::removeSourceItem(StationTreeModel* model, const std::string &name) { for (int i = 0; i < _rootItem->childCount(); i++) diff --git a/Gui/VtkVis/VtkVisPipeline.h b/Gui/VtkVis/VtkVisPipeline.h index 39d9c51cd594edfcb73c3a63349e8f6ff75e1c97..f87f2d4b2689de52f77e796c975581029a565526 100644 --- a/Gui/VtkVis/VtkVisPipeline.h +++ b/Gui/VtkVis/VtkVisPipeline.h @@ -17,7 +17,6 @@ // ** INCLUDES ** #include "Color.h" -#include "FEMCondition.h" #include "GeoType.h" #include "MeshEnums.h" #include "Point.h" @@ -99,7 +98,6 @@ public slots: /// \brief Adds the given Model to the pipeline. void addPipelineItem(MshModel* model, const QModelIndex &idx); void addPipelineItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type); - void addPipelineItem(ProcessModel* model, const FiniteElement::ProcessType pcs_type, FEMCondition::CondType cond_type); void addPipelineItem(StationTreeModel* model, const std::string &name); QModelIndex addPipelineItem(VtkVisPipelineItem* item, const QModelIndex &parent); @@ -109,7 +107,6 @@ public slots: /// \brief Removes the given Model (and all attached vtkAlgorithms) from the pipeline. void removeSourceItem(MshModel* model, const QModelIndex &idx); void removeSourceItem(GeoTreeModel* model, const std::string &name, GeoLib::GEOTYPE type); - void removeSourceItem(ProcessModel* model, const FiniteElement::ProcessType pcs_type, FEMCondition::CondType cond_type); void removeSourceItem(StationTreeModel* model, const std::string &name); /// \brief Removes the vtkAlgorithm at the given QModelIndex (and all attached diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index 611f095759bc6384a9264e6c86bfc8f59b27cd2e..4e14dacfc53b226ac0adbcd1d56557edf79ff51f 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -22,7 +22,6 @@ #include "FileTools.h" // models -#include "ProcessModel.h" #include "ElementTreeModel.h" #include "GEOModels.h" #include "GeoTreeModel.h" @@ -33,11 +32,8 @@ #include "Raster.h" //dialogs -#include "CondFromRasterDialog.h" -#include "ConditionWriterDialog.h" #include "DataExplorerSettingsDialog.h" #include "DiagramPrefsDialog.h" -#include "FEMConditionSetupDialog.h" #include "GeoOnMeshMappingDialog.h" #include "GMSHPrefsDialog.h" #include "LicenseDialog.h" @@ -48,7 +44,6 @@ #include "MeshElementRemovalDialog.h" #include "MshQualitySelectionDialog.h" #include "NetCdfConfigureDialog.h" -#include "NewProcessDialog.h" #include "SetNameDialog.h" #include "VisPrefsDialog.h" #include "VtkAddFilterDialog.h" @@ -65,11 +60,6 @@ #include "VtkVisPipeline.h" #include "VtkVisPipelineItem.h" -// FEM Conditions -#include "BoundaryCondition.h" -#include "InitialCondition.h" -#include "SourceTerm.h" - // FileIO includes #include "FEFLOWInterface.h" #include "GMSInterface.h" @@ -78,7 +68,6 @@ #include "GMSHInterface.h" #include "TetGenInterface.h" #include "PetrelInterface.h" -#include "XmlIO/Qt/XmlCndInterface.h" #include "XmlIO/Qt/XmlGmlInterface.h" #include "XmlIO/Qt/XmlGspInterface.h" #include "XmlIO/Qt/XmlStnInterface.h" @@ -130,7 +119,7 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) // Setup various models _meshModels = new MshModel(_project); _elementModel = new ElementTreeModel(); - _processModel = new ProcessModel(_project); + _processModel = new TreeModel(); GEOModels* geo_models(dynamic_cast<GEOModels*>(_project.getGEOObjects())); geoTabWidget->treeView->setModel(geo_models->getGeoModel()); @@ -169,10 +158,6 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) this, SLOT(showLineEditDialog(const std::string &))); // open line edit dialog connect(geoTabWidget->treeView, SIGNAL(requestNameChangeDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t)), this, SLOT(showGeoNameDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t))); - connect(geoTabWidget->treeView, SIGNAL(requestCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool)), - this, SLOT(showCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool))); - connect(geoTabWidget->treeView, SIGNAL(loadFEMCondFileRequested(std::string)), - this, SLOT(loadFEMConditions(std::string))); // add FEM Conditions to geometry connect(geo_models, SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), this, SLOT(updateDataViews())); connect(geo_models, SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), @@ -199,8 +184,6 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) this, SLOT(showMshQualitySelectionDialog(VtkMeshSource*))); connect(mshTabWidget->treeView, SIGNAL(requestMeshToGeometryConversion(const MeshLib::Mesh*)), this, SLOT(convertMeshToGeometry(const MeshLib::Mesh*))); - connect(mshTabWidget->treeView, SIGNAL(requestCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool)), - this, SLOT(showCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool))); connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)), _vtkVisPipeline, SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool))); connect(mshTabWidget->treeView, SIGNAL(meshSelected(MeshLib::Mesh const*const)), @@ -221,19 +204,6 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) _vtkVisPipeline, SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool))); connect(mshTabWidget->elementView, SIGNAL(removeSelectedMeshComponent()), _vtkVisPipeline, SLOT(removeHighlightedMeshComponent())); - connect(mshTabWidget->treeView, SIGNAL(loadFEMCondFileRequested(std::string)), - this, SLOT(loadFEMConditions(std::string))); // add FEM Conditions to mesh - - - // Setup connections for process model to GUI - connect(modellingTabWidget->treeView, SIGNAL(conditionsRemoved(const FiniteElement::ProcessType, const std::string&, const FEMCondition::CondType)), - _processModel, SLOT(removeConditions(const FiniteElement::ProcessType, const std::string&, const FEMCondition::CondType))); - connect(modellingTabWidget->treeView, SIGNAL(processRemoved(const FiniteElement::ProcessType)), - _processModel, SLOT(removeProcess(const FiniteElement::ProcessType))); - connect(modellingTabWidget, SIGNAL(requestNewProcess()), - this, SLOT(showNewProcessDialog())); - connect(modellingTabWidget->treeView, SIGNAL(saveConditionsRequested()), - this, SLOT(showConditionWriterDialog())); // VisPipeline Connects connect(geo_models, SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), @@ -241,11 +211,6 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) connect(geo_models, SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), _vtkVisPipeline, SLOT(removeSourceItem(GeoTreeModel *, std::string, GeoLib::GEOTYPE))); - connect(_processModel, SIGNAL(conditionAdded(ProcessModel *, const FiniteElement::ProcessType, const FEMCondition::CondType)), - _vtkVisPipeline, SLOT(addPipelineItem(ProcessModel *, const FiniteElement::ProcessType, const FEMCondition::CondType))); - connect(_processModel, SIGNAL(conditionsRemoved(ProcessModel *, const FiniteElement::ProcessType, const FEMCondition::CondType)), - _vtkVisPipeline, SLOT(removeSourceItem(ProcessModel *, const FiniteElement::ProcessType, const FEMCondition::CondType))); - connect(geo_models, SIGNAL(stationVectorAdded(StationTreeModel *, std::string)), _vtkVisPipeline, SLOT(addPipelineItem(StationTreeModel *, std::string))); connect(geo_models, SIGNAL(stationVectorRemoved(StationTreeModel *, std::string)), @@ -544,7 +509,6 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) if (xml.readFile(fileName)) { _meshModels->updateModel(); - _processModel->updateModel(); } else OGSError::box("Failed to load project file.\n Please see console for details."); @@ -583,10 +547,6 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) INFO("Mesh model setup time: %d ms.", myTimer1.elapsed()); #endif } - else if (fi.suffix().toLower() == "cnd") - { - this->loadFEMConditionsFromFile(fileName); - } settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); emit fileUsed(fileName); @@ -850,103 +810,6 @@ void MainWindow::showAddPipelineFilterItemDialog(QModelIndex parentIndex) dlg.exec(); } -void MainWindow::loadFEMConditions(std::string geoName) -{ - QSettings settings; - QString fileName = QFileDialog::getOpenFileName( this, "Select data file to open", - settings.value("lastOpenedFileDirectory").toString(), - "OpenGeosys FEM condition files (*.cnd);;All files (* *.*)"); - QDir dir = QDir(fileName); - settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); - - if (!fileName.isEmpty()) - this->loadFEMConditionsFromFile(fileName, geoName); -} - -void MainWindow::createFEMConditions(std::vector<FEMCondition*> const& conditions) -{ - this->_project.addConditions(conditions); - this->addFEMConditions(conditions); -} - -void MainWindow::loadFEMConditionsFromFile(const QString &fileName, std::string geoName) -{ - Q_UNUSED(geoName); - QFileInfo fi(fileName); - if (fi.suffix().toLower() == "cnd") - { - QSettings settings; - QDir dir = QDir(fileName); - settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); - std::vector<FEMCondition*> conditions; - XmlCndInterface xml(_project); - std::size_t const n_cond_before(this->_project.getConditions().size()); - if (xml.readFile(fileName)) { - std::size_t const n_cond_after(this->_project.getConditions().size()); - std::vector<FEMCondition*> conditions; - conditions.resize(n_cond_after-n_cond_before); - for (std::size_t k(n_cond_before); k<n_cond_after; k++) { - conditions[k-n_cond_before] = this->_project.getConditions()[k]; - } - this->addFEMConditions(conditions); - } else - OGSError::box("Failed to load FEM conditions.\n Please see console for details."); - } -} - -void MainWindow::addFEMConditions(std::vector<FEMCondition*> const& conditions) -{ - if (conditions.empty()) - return; - for (size_t i = 0; i < conditions.size(); i++) - { - bool condition_ok(true); - if (conditions[i]->getProcessDistributionType() == FiniteElement::DIRECT || - conditions[i]->getProcessDistributionType() == FiniteElement::NODESCONSTANT) - { - if (_meshModels->getMesh(conditions[i]->getAssociatedGeometryName()) != NULL) { - const std::vector<MeshLib::Node*> &nodes = _meshModels->getMesh(conditions[i]->getAssociatedGeometryName())->getNodes(); - const size_t nPoints(nodes.size()); - std::vector<GeoLib::Point*> *new_points = new std::vector<GeoLib::Point*>(nPoints); - for (size_t j = 0; j < nPoints; j++) - (*new_points)[j] = new GeoLib::Point(nodes[j]->getCoords()); - if (conditions[i]->getProcessDistributionType() == FiniteElement::DIRECT) - { - const GeoLib::PointVec pnt_vec("MeshNodes", new_points); - std::vector<GeoLib::Point*> *cond_points = pnt_vec.getSubset(conditions[i]->getDisNodes()); - std::for_each(new_points->begin(), new_points->end(), [](GeoLib::Point const*const pnt){delete pnt;} ); - new_points->clear(); - new_points = cond_points; - } - std::string geo_name = conditions[i]->getGeoName(); - this->_project.getGEOObjects()->addPointVec(new_points, geo_name); - conditions[i]->setGeoName(geo_name); // this might have been changed upon inserting it into geo_objects - } else { - OGSError::box("Please load the referenced mesh first", "Error"); - condition_ok = false; - } - } - if (condition_ok) { - this->_processModel->addCondition(conditions[i]); - } - } -} - -void MainWindow::writeFEMConditionsToFile(const QString &geoName, const FEMCondition::CondType type, const QString &fileName) -{ - std::string file_name (fileName.toStdString()); - if (BaseLib::getFileExtension(file_name).compare("cnd")) - file_name.append(".cnd"); - if (BaseLib::IsFileExisting(file_name)) - if (!OGSError::question("File already exists.\nOverwrite file?", "Warning")) - return; - - XmlCndInterface xml(_project); - xml.setNameForExport(geoName.toStdString()); - xml.setConditionType(type); - xml.writeToFile(file_name); -} - void MainWindow::writeGeometryToFile(QString gliName, QString fileName) { #ifndef NDEBUG @@ -1137,14 +1000,6 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, QApplication::restoreOverrideCursor(); } -void MainWindow::showConditionWriterDialog() -{ - ConditionWriterDialog dlg(_project.getGEOObjects()); - connect(&dlg , SIGNAL(saveFEMConditionsRequested(const QString&, const FEMCondition::CondType, const QString&)), - this, SLOT(writeFEMConditionsToFile(const QString&, const FEMCondition::CondType, const QString&))); - dlg.exec(); -} - void MainWindow::showDiagramPrefsDialog(QModelIndex &index) { QString listName; @@ -1208,51 +1063,6 @@ void MainWindow::showMeshAnalysisDialog() dlg->exec(); } -void MainWindow::showCondSetupDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, size_t id, bool on_points) -{ - std::string geo_name(""); - if (object_type != GeoLib::GEOTYPE::INVALID) - geo_name = this->_project.getGEOObjects()->getElementNameByID(geometry_name, object_type, id); - else - geo_name = geometry_name; // in this case this is actually the mesh name - - if (geo_name.empty()) - { - this->showGeoNameDialog(geometry_name, object_type, id); - geo_name = this->_project.getGEOObjects()->getElementNameByID(geometry_name, object_type, id); - } - // Object should now have a name ... if not, cancel the setup process - if (geo_name.empty()) - OGSError::box("FEM Condition Setup canceled."); - else - { - if (on_points) - dynamic_cast<GEOModels*>(_project.getGEOObjects())->addNameForObjectPoints(geometry_name, object_type, geo_name, geometry_name); - - if (object_type != GeoLib::GEOTYPE::INVALID) - { - FEMConditionSetupDialog dlg(geometry_name, object_type, geo_name, this->_project.getGEOObjects()->getGeoObject(geometry_name, object_type, geo_name), on_points); - connect(&dlg, SIGNAL(createFEMCondition(std::vector<FEMCondition*>)), this, SLOT(createFEMConditions(std::vector<FEMCondition*>))); - dlg.exec(); - } - else - { - const MeshLib::Mesh* mesh = _project.getMesh(geo_name); - FEMConditionSetupDialog dlg(geo_name, mesh); - connect(&dlg, SIGNAL(createFEMCondition(std::vector<FEMCondition*>)), this, SLOT(createFEMConditions(std::vector<FEMCondition*>))); - dlg.exec(); - } - } -} - -void MainWindow::showNewProcessDialog() -{ - NewProcessDialog dlg; - connect(&dlg , SIGNAL(addProcess(ProcessInfo*)), - _processModel, SLOT(addProcess(ProcessInfo*))); - dlg.exec(); -} - void MainWindow::showLineEditDialog(const std::string &geoName) { LineEditDialog lineEdit(*(_project.getGEOObjects()->getPolylineVecObj(geoName))); diff --git a/Gui/mainwindow.h b/Gui/mainwindow.h index 73dcf97ca7a3161362976d5c27f3419de4fd263c..2a5af6d66dced8143c4a81c02cdc652c8f9209b7 100644 --- a/Gui/mainwindow.h +++ b/Gui/mainwindow.h @@ -15,7 +15,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "ProjectData.h" +#include "Applications/ProjectData.h" #include "ImportFileTypes.h" #include "ui_mainwindow.h" @@ -49,7 +49,6 @@ public: protected: void closeEvent( QCloseEvent* event ); - void addFEMConditions(std::vector<FEMCondition*> const& conditions); protected slots: void showGeoDockWidget( bool show ); @@ -76,15 +75,11 @@ protected slots: /// Testing functionality for connection to FEM lib void FEMTestStart(); void loadPetrelFiles(); - void loadFEMConditions(std::string geoName); void mapGeometry(const std::string &geo_name); void convertMeshToGeometry(const MeshLib::Mesh* mesh); void openRecentFile(); void about(); void showAddPipelineFilterItemDialog(QModelIndex parentIndex); - void showConditionWriterDialog(); - /// Call dialog for creating or modifying FEM conditions. - void showCondSetupDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id, bool on_points = false); void showDataExplorerSettingsDialog(); /// Allows setting the name for a geometric object void showGeoNameDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id); @@ -101,13 +96,10 @@ protected slots: void showMergeGeometriesDialog(); void showMeshAnalysisDialog(); void showMshQualitySelectionDialog(VtkMeshSource* mshSource); - void showNewProcessDialog(); void showPropertiesDialog(std::string const& name); void showVisalizationPrefsDialog(); void showTrackingSettingsDialog(); void updateDataViews(); - void createFEMConditions(std::vector<FEMCondition*> const& conditions); - void writeFEMConditionsToFile(const QString &geoName, const FEMCondition::CondType type, const QString &fileName); void writeGeometryToFile(QString listName, QString fileName); void writeStationListToFile(QString listName, QString fileName); @@ -132,7 +124,7 @@ private: MshModel* _meshModels; ElementTreeModel* _elementModel; - ProcessModel* _processModel; + TreeModel* _processModel; ProjectData _project; VtkVisPipeline* _vtkVisPipeline; QList<QRect> _screenGeometries; diff --git a/OGS/BoundaryCondition.cpp b/OGS/BoundaryCondition.cpp deleted file mode 100644 index b5913f15a552c0cfa3ad3ec4ab8faabf19da8b94..0000000000000000000000000000000000000000 --- a/OGS/BoundaryCondition.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Implementation of the BoundaryCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ -/* -#include "BoundaryCondition.h" - -#include "rf_bc_new.h" - -BoundaryCondition::BoundaryCondition(const CBoundaryCondition &bc, const std::string &geometry_name) - : FEMCondition(geometry_name, bc.getProcessType(), bc.getProcessPrimaryVariable(), - bc.getGeomType(), bc.getGeoName(), - bc.getProcessDistributionType(), FEMCondition::BOUNDARY_CONDITION) -{ - if (this->getProcessDistributionType() == FiniteElement::CONSTANT || - this->getProcessDistributionType() == FiniteElement::CONSTANT_NEUMANN) - this->setConstantDisValue(bc.getGeoNodeValue()); - else if (this->getProcessDistributionType() == FiniteElement::LINEAR || - this->getProcessDistributionType() == FiniteElement::LINEAR_NEUMANN) - { - const std::vector<int> bc_nodes(bc.getPointsWithDistribedBC()); - std::vector<size_t> dis_nodes(bc_nodes.size()); - for (size_t i=0; i<dis_nodes.size(); i++) dis_nodes[i] = static_cast<size_t>(bc_nodes[i]); - this->setDisValues(dis_nodes, bc.getDistribedBC()); - } -} -*/ diff --git a/OGS/BoundaryCondition.h b/OGS/BoundaryCondition.h deleted file mode 100644 index b8581c6065ab4521d2a48d258b9377e0e1b86d30..0000000000000000000000000000000000000000 --- a/OGS/BoundaryCondition.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Definition of the BoundaryCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef BOUNDARYCONDITION_H -#define BOUNDARYCONDITION_H - -#include "FEMCondition.h" - -/** - * \brief Adapter class for handling boundary conditions in the user Interface - * \sa FEMCondition - */ -class BoundaryCondition : public FEMCondition -{ -public: - BoundaryCondition(const std::string &geometry_name) - : FEMCondition(geometry_name, FEMCondition::BOUNDARY_CONDITION), _tim_type(0) {}; - BoundaryCondition(const FEMCondition &cond) - : FEMCondition(cond, FEMCondition::BOUNDARY_CONDITION) {}; - ~BoundaryCondition() {} - - std::size_t getTimType() const {return _tim_type; } - void setTimType(std::size_t value) { _tim_type = value; } - -private: - std::size_t _tim_type; -}; - -#endif //BOUNDARYCONDITION_H diff --git a/OGS/CMakeLists.txt b/OGS/CMakeLists.txt deleted file mode 100644 index 588316e6c37afe09f047c8c88544320caff5ad08..0000000000000000000000000000000000000000 --- a/OGS/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Source files -GET_SOURCE_FILES(SOURCES_OGSLIB) -SET ( SOURCES ${SOURCES_OGSLIB}) - -# Create the library -ADD_LIBRARY(OgsLib STATIC ${SOURCES}) - -include_directories( - . - ${CMAKE_CURRENT_SOURCE_DIR}/../BaseLib - ${CMAKE_CURRENT_SOURCE_DIR}/../GeoLib - ${CMAKE_CURRENT_SOURCE_DIR}/../MathLib - ${CMAKE_CURRENT_SOURCE_DIR}/../MeshLib -) - - -target_link_libraries (OgsLib - BaseLib - GeoLib - MeshLib -) - diff --git a/OGS/DistributionInfo.cpp b/OGS/DistributionInfo.cpp deleted file mode 100644 index 37cf067dc84cd4afa034373581cb00578336e7ac..0000000000000000000000000000000000000000 --- a/OGS/DistributionInfo.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-09-28 - * \brief Implementation of the DistributionInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "DistributionInfo.h" - -DistributionInfo::DistributionInfo(FiniteElement::DistributionType dt) : - _dis_type (dt) -{} - -DistributionInfo::~DistributionInfo() -{} - -void DistributionInfo::setProcessDistributionType (FiniteElement::DistributionType dis_type) - -{ - _dis_type = dis_type; -} - -FiniteElement::DistributionType DistributionInfo::getProcessDistributionType () const -{ - return _dis_type; -} diff --git a/OGS/DistributionInfo.h b/OGS/DistributionInfo.h deleted file mode 100644 index 59c19df9f52916f05f45b3178b29710105ab51b2..0000000000000000000000000000000000000000 --- a/OGS/DistributionInfo.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-09-28 - * \brief Definition of the DistributionInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef DISTRIBUTIONINFO_H_ -#define DISTRIBUTIONINFO_H_ - -// FEM -#include "FEMEnums.h" - -class DistributionInfo -{ -public: - DistributionInfo(FiniteElement::DistributionType dt = FiniteElement::INVALID_DIS_TYPE); - virtual ~DistributionInfo(); - - /** - * Sets the value for the distribution type - * @param dis_type value for primary variable, possible values are documented in enum PrimaryVariable - */ - void setProcessDistributionType (FiniteElement::DistributionType dis_type); - - /** - * Get the distribution type of the process. - * @return the distribution type of the process - */ - FiniteElement::DistributionType getProcessDistributionType () const; - -private: - /** - * the distribution type of the process, see enum DistributionType for valid values - */ - FiniteElement::DistributionType _dis_type; -}; - -#endif /* DISTRIBUTIONINFO_H_ */ diff --git a/OGS/FEMCondition.cpp b/OGS/FEMCondition.cpp deleted file mode 100644 index 68f98d2bc10fae755936a072eb1945c72f50b00e..0000000000000000000000000000000000000000 --- a/OGS/FEMCondition.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-11-25 - * \brief Implementation of the FEMCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "FEMCondition.h" - -FEMCondition::FEMCondition(const std::string &geometry_name, CondType t) - : _type(t), _geoName("[unspecified]"), _associated_geometry(geometry_name) -{ - this->setProcessType(FiniteElement::INVALID_PROCESS); - this->setProcessPrimaryVariable(FiniteElement::INVALID_PV); - this->setGeoType(GeoLib::GEOTYPE::INVALID); - this->setProcessDistributionType(FiniteElement::INVALID_DIS_TYPE); -} - -FEMCondition::FEMCondition(const std::string &geometry_name, - FiniteElement::ProcessType pt, - FiniteElement::PrimaryVariable pv, - GeoLib::GEOTYPE gt, - const std::string &gn, - FiniteElement::DistributionType dt, - CondType ct) - : ProcessInfo(pt, pv/*, NULL*/), GeoInfo(gt, NULL), DistributionInfo(dt), _type(ct), - _geoName(gn), _associated_geometry(geometry_name) -{ -} - -FEMCondition::FEMCondition(const FEMCondition &cond, CondType t) - : ProcessInfo(cond.getProcessType(), cond.getProcessPrimaryVariable() /*, NULL*/), - GeoInfo(cond.getGeomType(), cond.getGeoObj()), - DistributionInfo(cond.getProcessDistributionType()), - _type(t), - _geoName(cond.getGeoName()), - _disNodes(cond.getDisNodes()), - _disValues(cond.getDisValues()), - _associated_geometry(cond.getAssociatedGeometryName()) -{ -} - -std::string FEMCondition::condTypeToString(CondType type) -{ - if (type == FEMCondition::BOUNDARY_CONDITION) - return "Boundary Conditions"; - else if (type == FEMCondition::INITIAL_CONDITION) - return "Initial Conditions"; - else if (type == FEMCondition::SOURCE_TERM) - return "Source Terms"; - else - return "Unspecified"; -} - -void FEMCondition::setDisValues(const std::vector< std::pair<size_t, double> > &dis_values) -{ - std::vector<size_t> nodes; - std::vector<double> values; - for (size_t i = 0; i < dis_values.size(); i++) - { - nodes.push_back(dis_values[i].first); - values.push_back(dis_values[i].second); - } - this->_disNodes = nodes; - this->_disValues = values; -} - -void FEMCondition::initGeometricAttributes(std::string const& geo_name, - GeoLib::GEOTYPE geo_obj_type, - std::string const& geo_obj_name, - GeoLib::GEOObjects const& geo_objs) -{ - _associated_geometry = geo_name; - setGeoType(geo_obj_type); - _geoName = geo_obj_name; - setGeoObj(geo_objs.getGeoObject(_associated_geometry, _geo_type, _geoName)); -} diff --git a/OGS/FEMCondition.h b/OGS/FEMCondition.h deleted file mode 100644 index b382c42a8696358390d0da6b309c1dec57fcd639..0000000000000000000000000000000000000000 --- a/OGS/FEMCondition.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-11-25 - * \brief Definition of the FEMCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef FEMCONDITION_H -#define FEMCONDITION_H - -#include <vector> - -#include "DistributionInfo.h" -#include "GeoInfo.h" -#include "ProcessInfo.h" - -// GeoLib -#include "GEOObjects.h" - -/** - * \brief Adapter class for handling FEM Conditions in the user Interface - */ -class FEMCondition : public ProcessInfo, public GeoInfo, public DistributionInfo -{ -public: - /// Specifier for types of FEM Conditions - enum CondType { - UNSPECIFIED = 0, - BOUNDARY_CONDITION = 1, - INITIAL_CONDITION = 2, - SOURCE_TERM = 3 - }; - - FEMCondition(const std::string &geometry_name, CondType t = UNSPECIFIED); - FEMCondition(const std::string &geometry_name, - FiniteElement::ProcessType pt = FiniteElement::INVALID_PROCESS, - FiniteElement::PrimaryVariable pv = FiniteElement::INVALID_PV, - GeoLib::GEOTYPE gt = GeoLib::GEOTYPE::INVALID, - const std::string &gn = "[unspecified]", - FiniteElement::DistributionType dt = FiniteElement::INVALID_DIS_TYPE, - CondType ct = UNSPECIFIED); - FEMCondition(const FEMCondition &cond, CondType t); - - ~FEMCondition() {} - - /// Returns the type of the FEM Condition (i.e. BC, IC or ST) - CondType getCondType() const { return _type; } - - /// Returns the value(s) for the distribution - std::vector<std::size_t> const& getDisNodes() const { return _disNodes; } - - /// Returns the value(s) for the distribution - std::vector<double> const& getDisValues() const { return _disValues; } - - /// Returns the name of the geo-object the condition is assigned to. This object is part of the associated geometry. - const std::string& getGeoName() const { return _geoName; } - - /// Returns the name of the associated geometry. - const std::string& getAssociatedGeometryName() const { return _associated_geometry; } - - /// Convenience method for setting a single value specifying the distribution. - void setConstantDisValue(double disValue) {_disValues.clear(); _disValues.push_back(disValue); } - - /// Sets a vector of values specifying the distribution. - void setDisValues(const std::vector<std::size_t> &disNodes, - const std::vector<double> &disValues) - { - _disNodes = disNodes; - _disValues = disValues; - } - - /// Sets a vector of values specifying the distribution. - /// The first value specifies the point id, the second the value for that point. - void setDisValues(const std::vector< std::pair<std::size_t, double> > &dis_values); - - /// Removes all distribution values - void clearDisValues() { _disValues.resize(0); } - - /// Sets the name of the geo-object the condition is assigned to. - void setGeoName(std::string const& geoName) { _geoName = geoName; } - - /// Returns the type of the FEM condition as a string. - static std::string condTypeToString(CondType type); - - /** - * - * @param geo_name the name of the geometry - * @param geo_obj_type type of geometric object (POINT, POLYLINE, SURFACE) @see GeoLib::GEOTYPE - * @param geo_obj_name name of the geometric object - * @param geo_objs instance of class GEOObjects is employed for getting - * the pointer of the geometric object (GEOObjects::getGeoObject()) - */ - void initGeometricAttributes(std::string const& geo_name, - GeoLib::GEOTYPE geo_obj_type, - std::string const& geo_obj_name, - GeoLib::GEOObjects const& geo_objs); - -protected: - CondType _type; - std::string _geoName; - std::vector<std::size_t> _disNodes; - std::vector<double> _disValues; - std::string _associated_geometry; -}; - -#endif //FEMCONDITION_H diff --git a/OGS/FEMEnums.cpp b/OGS/FEMEnums.cpp deleted file mode 100644 index f9c9c877d7d574ffcf671a9bd3a78f677a6aec89..0000000000000000000000000000000000000000 --- a/OGS/FEMEnums.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-09-02 - * \brief Implementation of fem enumerations. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "FEMEnums.h" - -// STL -#include <cstdlib> - -namespace FiniteElement -{ -ProcessType convertProcessType ( const std::string& pcs_type_string ) -{ - if (pcs_type_string.compare ("LIQUID_FLOW") == 0) - return LIQUID_FLOW; - if (pcs_type_string.compare ("FLUID_FLOW") == 0) - return FLUID_FLOW; - if (pcs_type_string.compare ("TWO_PHASE_FLOW") == 0) - return TWO_PHASE_FLOW; - if (pcs_type_string.compare ("RICHARDS_FLOW") == 0) - return RICHARDS_FLOW; - if (pcs_type_string.compare ("OVERLAND_FLOW") == 0) - return OVERLAND_FLOW; - if (pcs_type_string.compare ("GROUNDWATER_FLOW") == 0) - return GROUNDWATER_FLOW; - if (pcs_type_string.compare ("HEAT_TRANSPORT") == 0) - return HEAT_TRANSPORT; - if (pcs_type_string.compare ("DEFORMATION") == 0) - return DEFORMATION; - if (pcs_type_string.compare ("DEFORMATION_FLOW") == 0) - return DEFORMATION_FLOW; - if (pcs_type_string.compare ("DEFORMATION_DYNAMIC") == 0) - return DEFORMATION_DYNAMIC; - if (pcs_type_string.compare ("MASS_TRANSPORT") == 0) - return MASS_TRANSPORT; - if (pcs_type_string.compare ("MULTI_PHASE_FLOW") == 0) - return MULTI_PHASE_FLOW; - if (pcs_type_string.compare ("DEFORMATION_H2") == 0) - return DEFORMATION_H2; - if (pcs_type_string.compare ("AIR_FLOW") == 0) - return AIR_FLOW; - if (pcs_type_string.compare ("FLUID_MOMENTUM") == 0) - return FLUID_MOMENTUM; - if (pcs_type_string.compare ("RANDOM_WALK") == 0) - return RANDOM_WALK; - if (pcs_type_string.compare ("FLUX") == 0) - return FLUX; - if (pcs_type_string.compare ("PS_GLOBAL") == 0) - return PS_GLOBAL; - if (pcs_type_string.compare ("NO_PCS") == 0) - return NO_PCS; - if (pcs_type_string.compare ("PTC_FLOW") == 0) - return PTC_FLOW; - return INVALID_PROCESS; -} - -std::string convertProcessTypeToString ( ProcessType pcs_type ) -{ - if (pcs_type == LIQUID_FLOW) - return "LIQUID_FLOW"; - if (pcs_type == FLUID_FLOW) - return "FLUID_FLOW"; - if (pcs_type == TWO_PHASE_FLOW) - return "TWO_PHASE_FLOW"; - if (pcs_type == RICHARDS_FLOW) - return "RICHARDS_FLOW"; - if (pcs_type == OVERLAND_FLOW) - return "OVERLAND_FLOW"; - if (pcs_type == GROUNDWATER_FLOW) - return "GROUNDWATER_FLOW"; - if (pcs_type == HEAT_TRANSPORT) - return "HEAT_TRANSPORT"; - if (pcs_type == DEFORMATION) - return "DEFORMATION"; - if (pcs_type == DEFORMATION_FLOW) - return "DEFORMATION_FLOW"; - if (pcs_type == DEFORMATION_DYNAMIC) - return "DEFORMATION_DYNAMIC"; - if (pcs_type == MASS_TRANSPORT) - return "MASS_TRANSPORT"; - if (pcs_type == MULTI_PHASE_FLOW) - return "MULTI_PHASE_FLOW"; - if (pcs_type == DEFORMATION_H2) - return "DEFORMATION_H2"; - if (pcs_type == AIR_FLOW) - return "AIR_FLOW"; - if (pcs_type == FLUID_MOMENTUM) - return "FLUID_MOMENTUM"; - if (pcs_type == RANDOM_WALK) - return "RANDOM_WALK"; - if (pcs_type == FLUX) - return "FLUX"; - if (pcs_type == PS_GLOBAL) - return "PS_GLOBAL"; - if (pcs_type == PTC_FLOW) - return "PTC_FLOW"; - if (pcs_type == NO_PCS) - return "NO_PCS"; - return "INVALID_PROCESS"; -} - -bool isFlowProcess (ProcessType pcs_type) -{ - if ( pcs_type == LIQUID_FLOW || pcs_type == FLUID_FLOW - || pcs_type == RICHARDS_FLOW || pcs_type == GROUNDWATER_FLOW - || pcs_type == PS_GLOBAL || pcs_type == MULTI_PHASE_FLOW - || pcs_type == DEFORMATION_FLOW || pcs_type == DEFORMATION_H2 - || pcs_type == TWO_PHASE_FLOW || pcs_type == OVERLAND_FLOW - || pcs_type == AIR_FLOW || pcs_type == PTC_FLOW) - return true; - return false; -} - -bool isMultiFlowProcess (ProcessType pcs_type) -{ - if (pcs_type == PS_GLOBAL || - pcs_type == MULTI_PHASE_FLOW || - pcs_type == TWO_PHASE_FLOW || - pcs_type == DEFORMATION_H2) - return true; - return false; -} - -bool isDeformationProcess (ProcessType pcs_type) -{ - if (pcs_type == DEFORMATION || pcs_type == DEFORMATION_H2 || - pcs_type == DEFORMATION_FLOW || pcs_type == DEFORMATION_DYNAMIC) - return true; - return false; -} - -const std::list<std::string> getAllProcessNames() -{ - size_t count(1); - std::list<std::string> enum_names; - - while (count != PROCESS_END) - { - enum_names.push_back( convertProcessTypeToString(static_cast<ProcessType>(count++)) ); - } - return enum_names; -} - - -PrimaryVariable convertPrimaryVariable ( const std::string& pcs_pv_string ) -{ - if (pcs_pv_string.compare ("PRESSURE1") == 0) - return PRESSURE; - if (pcs_pv_string.compare ("PRESSURE2") == 0) - return PRESSURE2; - if (pcs_pv_string.compare ("PRESSURE_RATE1") == 0) - return PRESSURE_RATE1; - if (pcs_pv_string.compare ("SATURATION1") == 0) - return SATURATION; - if (pcs_pv_string.compare ("SATURATION2") == 0) - return SATURATION2; - if (pcs_pv_string.compare ("TEMPERATURE1") == 0) - return TEMPERATURE; - if (pcs_pv_string.compare ("DISPLACEMENT_X1") == 0) - return DISPLACEMENT_X; - if (pcs_pv_string.compare ("DISPLACEMENT_Y1") == 0) - return DISPLACEMENT_Y; - if (pcs_pv_string.compare ("DISPLACEMENT_Z1") == 0) - return DISPLACEMENT_Z; - if (pcs_pv_string.compare ("CONCENTRATION1") == 0) - return CONCENTRATION; - if (pcs_pv_string.compare ("HEAD") == 0) - return HEAD; - if (pcs_pv_string.compare ("VELOCITY_DM_X") == 0) - return VELOCITY_DM_X; - if (pcs_pv_string.compare ("VELOCITY_DM_Y") == 0) - return VELOCITY_DM_Y; - if (pcs_pv_string.compare ("VELOCITY_DM_Z") == 0) - return VELOCITY_DM_Z; - if (pcs_pv_string.compare ("VELOCITY1_X") == 0) - return VELOCITY1_X; - if (pcs_pv_string.compare ("VELOCITY1_Y") == 0) - return VELOCITY1_Y; - if (pcs_pv_string.compare ("VELOCITY1_Z") == 0) - return VELOCITY1_Z; - if (pcs_pv_string.compare ("STRESS_XX") == 0) - return STRESS_XX; - if (pcs_pv_string.compare ("STRESS_XY") == 0) - return STRESS_XY; - if (pcs_pv_string.compare ("STRESS_XZ") == 0) - return STRESS_XZ; - if (pcs_pv_string.compare ("STRESS_YY") == 0) - return STRESS_YY; - if (pcs_pv_string.compare ("STRESS_YZ") == 0) - return STRESS_YZ; - if (pcs_pv_string.compare ("STRESS_ZZ") == 0) - return STRESS_ZZ; - if (pcs_pv_string.compare ("ACCELERATION_X1") == 0) - return ACCELERATION_X1; - if (pcs_pv_string.compare ("ACCELERATION_Y1") == 0) - return ACCELERATION_Y1; - if (pcs_pv_string.compare ("ACCELERATION_Z1") == 0) - return ACCELERATION_Z1; - if (pcs_pv_string.compare ("EXCAVATION") == 0) - return EXCAVATION; - if (pcs_pv_string.compare ("STRAIN_XX") == 0) - return STRAIN_XX; - if (pcs_pv_string.compare ("STRAIN_XY") == 0) - return STRAIN_XY; - if (pcs_pv_string.compare ("STRAIN_XZ") == 0) - return STRAIN_XZ; - if (pcs_pv_string.compare ("STRAIN_YY") == 0) - return STRAIN_YY; - if (pcs_pv_string.compare ("STRAIN_YZ") == 0) - return STRAIN_YZ; - if (pcs_pv_string.compare ("STRAIN_ZZ") == 0) - return STRAIN_ZZ; - if (pcs_pv_string.compare ("STRAIN_PLS") == 0) - return STRAIN_PLS; - return INVALID_PV; -} - -std::string convertPrimaryVariableToString ( PrimaryVariable pcs_pv ) -{ - if (pcs_pv == PRESSURE) - return "PRESSURE1"; - if (pcs_pv == PRESSURE2) - return "PRESSURE2"; - if (pcs_pv == PRESSURE_RATE1) - return "PRESSURE_RATE1"; - if (pcs_pv == SATURATION) - return "SATURATION1"; - if (pcs_pv == SATURATION2) - return "SATURATION2"; - if (pcs_pv == TEMPERATURE) - return "TEMPERATURE1"; - if (pcs_pv == DISPLACEMENT_X) - return "DISPLACEMENT_X1"; - if (pcs_pv == DISPLACEMENT_Y) - return "DISPLACEMENT_Y1"; - if (pcs_pv == DISPLACEMENT_Z) - return "DISPLACEMENT_Z1"; - if (pcs_pv == CONCENTRATION) - return "CONCENTRATION1"; - if (pcs_pv == HEAD) - return "HEAD"; - if (pcs_pv == VELOCITY_DM_X) - return "VELOCITY_DM_X"; - if (pcs_pv == VELOCITY_DM_Y) - return "VELOCITY_DM_Y"; - if (pcs_pv == VELOCITY_DM_Z) - return "VELOCITY_DM_Z"; - if (pcs_pv == VELOCITY1_X) - return "VELOCITY1_X"; - if (pcs_pv == VELOCITY1_Y) - return "VELOCITY1_Y"; - if (pcs_pv == VELOCITY1_Z) - return "VELOCITY1_Z"; - if (pcs_pv == STRESS_XX) - return "STRESS_XX"; - if (pcs_pv == STRESS_XY) - return "STRESS_XY"; - if (pcs_pv == STRESS_XZ) - return "STRESS_XZ"; - if (pcs_pv == STRESS_YY) - return "STRESS_YY"; - if (pcs_pv == STRESS_YZ) - return "STRESS_YZ"; - if (pcs_pv == STRESS_ZZ) - return "STRESS_ZZ"; - if (pcs_pv == STRAIN_XX) return "STRAIN_XX"; - if (pcs_pv == STRAIN_XY) return "STRAIN_XY"; - if (pcs_pv == STRAIN_XZ) return "STRAIN_XZ"; - if (pcs_pv == STRAIN_YY) return "STRAIN_YY"; - if (pcs_pv == STRAIN_YZ) return "STRAIN_YZ"; - if (pcs_pv == STRAIN_ZZ) return "STRAIN_ZZ"; - if (pcs_pv == STRAIN_PLS) return "STRAIN_PLS"; - if (pcs_pv == ACCELERATION_X1) - return "ACCELERATION_X1"; - if (pcs_pv == ACCELERATION_Y1) - return "ACCELERATION_Y1"; - if (pcs_pv == ACCELERATION_Z1) - return "ACCELERATION_Z1"; - if (pcs_pv == EXCAVATION) - return "EXCAVATION"; - return "INVALID_PRIMARY_VARIABLE"; -} - -const std::list<std::string> getAllPrimaryVariableNames() -{ - size_t count(1); - std::list<std::string> enum_names; - - while (count != PV_END) - { - enum_names.push_back( convertPrimaryVariableToString(static_cast<PrimaryVariable>(count++)) ); - } - return enum_names; -} - -DistributionType convertDisType(const std::string& dis_type_string) -{ - if (dis_type_string.compare("CONSTANT") == 0) - return CONSTANT; - if (dis_type_string.compare("ANALYTICAL") == 0) - return ANALYTICAL; - if (dis_type_string.compare("AVERAGE") == 0) - return AVERAGE; - if (dis_type_string.compare("CONSTANT_GEO") == 0) - return CONSTANT_GEO; - if (dis_type_string.compare("GRADIENT") == 0) - return GRADIENT; - if (dis_type_string.compare("RESTART") == 0) - return RESTART; - if (dis_type_string.compare("LINEAR") == 0) - return LINEAR; - if (dis_type_string.compare("POINT") == 0) - return POINT; - if (dis_type_string.compare("CONSTANT_NEUMANN") == 0) - return CONSTANT_NEUMANN; - if (dis_type_string.compare("LINEAR_NEUMANN") == 0) - return LINEAR_NEUMANN; - if (dis_type_string.compare("NORMALDEPTH") == 0) - return NORMALDEPTH; - if (dis_type_string.compare("CRITICALDEPTH") == 0) - return CRITICALDEPTH; - if (dis_type_string.compare("GREEN_AMPT") == 0) - return GREEN_AMPT; - if (dis_type_string.compare("SYSTEM_DEPENDENT") == 0) - return SYSTEM_DEPENDENT; - if (dis_type_string.compare("PRECIPITATION") == 0) - return PRECIPITATION; - if (dis_type_string.compare("DIRECT") == 0) - return DIRECT; - if (dis_type_string.compare("DOMAIN") == 0) - return NODESCONSTANT; - if (dis_type_string.compare("FUNCTION") == 0) - return FUNCTION; //24.08.2011. WW - - return INVALID_DIS_TYPE; -} - -std::string convertDisTypeToString(DistributionType dis_type) -{ - if (dis_type == ANALYTICAL) - return "ANALYTICAL"; - if (dis_type == AVERAGE) - return "AVERAGE"; - if (dis_type == CONSTANT) - return "CONSTANT"; - if (dis_type == CONSTANT_GEO) - return "CONSTANT_GEO"; - if (dis_type == GRADIENT) - return "GRADIENT"; - if (dis_type == RESTART) - return "RESTART"; - if (dis_type == LINEAR) - return "LINEAR"; - if (dis_type == POINT) - return "POINT"; - if (dis_type == CONSTANT_NEUMANN) - return "CONSTANT_NEUMANN"; - if (dis_type == LINEAR_NEUMANN) - return "LINEAR_NEUMANN"; - if (dis_type == NORMALDEPTH) - return "NORMALDEPTH"; - if (dis_type == CRITICALDEPTH) - return "CRITICALDEPTH"; - if (dis_type == GREEN_AMPT) - return "GREEN_AMPT"; - if (dis_type == SYSTEM_DEPENDENT) - return "SYSTEM_DEPENDENT"; - if (dis_type == PRECIPITATION) - return "PRECIPITATION"; - if (dis_type == DIRECT) - return "DIRECT"; - if (dis_type == NODESCONSTANT) - return "DOMAIN"; - if (dis_type == FUNCTION) - return "FUNCTION"; //24.08.2011. WW - - return "INVALID_DIS_TYPE"; -} - -const std::list<std::string> getAllDistributionNames() -{ - size_t count(1); - std::list<std::string> enum_names; - - while (count != DIS_END) - { - enum_names.push_back( convertDisTypeToString(static_cast<DistributionType>(count++)) ); - } - return enum_names; -} - -ErrorMethod convertErrorMethod(const std::string& error_method_string) -{ - if (error_method_string.compare("LMAX") == 0) - return LMAX; - if (error_method_string.compare("ENORM") == 0) - return ENORM; - if (error_method_string.compare("EVNORM") == 0) - return EVNORM; - if (error_method_string.compare("ERNORM") == 0) - return ERNORM; - if (error_method_string.compare("BNORM") == 0) - return BNORM; - - return INVALID_ERROR_METHOD; -} - -} // end namespace FiniteElement diff --git a/OGS/FEMEnums.h b/OGS/FEMEnums.h deleted file mode 100644 index c1fa77152a289ced628226ad2bfd041e5b5b3520..0000000000000000000000000000000000000000 --- a/OGS/FEMEnums.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-08-31 - * \brief Definition of fem enumerations. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef FEMENUMS_H -#define FEMENUMS_H - -#include <limits> -#include <string> -#include <list> - -namespace FiniteElement -{ -/** \brief Types of physical processes supported by OpenGeoSys. - * If you change this enum, make sure you apply the changes to - * the functions convertPorcessType(), convertProcessTypeToString(), - * isFlowProcess() and isDeformationProcess() - */ -enum ProcessType -{ - INVALID_PROCESS = 0, //!< INVALID_PROCESS - AIR_FLOW, //!< AIR_FLOW - /// M process, single/multi-phase flow - DEFORMATION, //!< DEFORMATION - DEFORMATION_DYNAMIC, //!< ... - /// C process, single/multi-phase flow - DEFORMATION_FLOW, //!< DEFORMATION_FLOW - /// H2M monolithic - DEFORMATION_H2, //!< DEFORMATION_H2 - FLUID_FLOW, - FLUID_MOMENTUM, // BC only - FLUX, - /// H process, incompressible flow - GROUNDWATER_FLOW, //!< GROUNDWATER_FLOW - /// T process, single/multi-phase flow - HEAT_TRANSPORT, //!< HEAT_TRANSPORT - /// H process, incompressible flow - LIQUID_FLOW, //!< LIQUID_FLOW - MASS_TRANSPORT, //!< MASS_TRANSPORT - MULTI_PHASE_FLOW, //!< MULTI_PHASE_FLOW - NO_PCS, //!< NO_PCS - /// H process, incompressible flow - OVERLAND_FLOW, //!< OVERLAND_FLOW - PS_GLOBAL, //!< PS_GLOBAL - PTC_FLOW, // Fluid flow coupled with heat transport - RANDOM_WALK, //!< RANDOM_WALK - /// H process, incompressible flow - RICHARDS_FLOW, //!< RICHARDS_FLOW - /// H2 process, compressible flow - TWO_PHASE_FLOW, //!< TWO_PHASE_FLOW - // make sure that this is always the last entry (important for iterating over the enum entries)! - PROCESS_END -}; - -/** - * \brief Convert the given string into the appropriate enum value. - * @param pcs_type_string string describing a process type - * @return enum value describing process type - */ -ProcessType convertProcessType ( const std::string& pcs_type_string ); - -/** - * \brief Convert the given enum value into the appropriate string. - * @param pcs_type process type described by the enum ProcessType - * @return string describing the process type - */ -std::string convertProcessTypeToString ( ProcessType pcs_type ); - -/** - * \brief Checks if the given pcs_type variable corresponds to a flow type of the enum ProcessType. - * @param pcs_type value of enum ProcessType - * @return true if pcs_type describes a flow process, else false - */ -bool isFlowProcess (ProcessType pcs_type); - -/** - * \brief Checks if the given pcs_type variable corresponds to a multiphase flow type of the enum ProcessType. - * @param pcs_type value of enum ProcessType - * @return true if pcs_type describes a flow process, else false - */ -bool isMultiFlowProcess (ProcessType pcs_type); - -/** - * \brief Checks if the given pcs_type variable corresponds to a deformation type of the enum ProcessType. - * @param pcs_type value of enum ProcessType - * @return true if pcs_type describes a deformation process, else false - */ -bool isDeformationProcess (ProcessType pcs_type); - -/// Returns a list of strings containing all entries in the ProcessType enum. -const std::list<std::string> getAllProcessNames(); - -/** - * \brief Contains all values for primary variables actually handled by OGS. - */ -enum PrimaryVariable -{ - INVALID_PV = 0, //!< INVALID_PV - ACCELERATION_X1, //!< ACCELERATION_X1 - ACCELERATION_Y1, //!< ACCELERATION_Y1 - ACCELERATION_Z1, //!< ACCELERATION_Z1 - /// Mass transport - CONCENTRATION, //!< CONCENTRATION - /// Deformation - DISPLACEMENT_X, //!< DISPLACEMENT_X - /// Deformation - DISPLACEMENT_Y, //!< DISPLACEMENT_Y - /// Deformation - DISPLACEMENT_Z, //!< DISPLACEMENT_Z - EXCAVATION, // ST - HEAD, //!< HEAD - /// Flow (phase) - PRESSURE, //!< PRESSURE - PRESSURE2, //!< PRESSURE2 - PRESSURE_RATE1, // OUT - SATURATION, //!< SATURATION - SATURATION2, //!< SATURATION2 - STRAIN_XX, // Output - STRAIN_XY, // Output - STRAIN_XZ, // Output - STRAIN_YY, // Output - STRAIN_YZ, // Output - STRAIN_ZZ, // Output - STRAIN_PLS, // Output - STRESS_XX, // IC - STRESS_XY, // IC - STRESS_XZ, // IC - STRESS_YY, // IC - STRESS_YZ, // IC - STRESS_ZZ, // IC - /// Heat transport - TEMPERATURE, //!< TEMPERATURE - VELOCITY_DM_X, //!< VELOCITY_DM_X - VELOCITY_DM_Y, //!< VELOCITY_DM_Y - VELOCITY_DM_Z, //!< VELOCITY_DM_Z - VELOCITY1_X, - VELOCITY1_Y, - VELOCITY1_Z, - // make sure that this is always the last entry (important for iterating over the enum entries)! - PV_END -}; - -/** - * \brief Converts the given string into the appropriate enum value. - * @param pcs_pv_string string describing the primary variable - * @return enum value describing the primary variable of the process - */ -//!< PrimaryVariable -PrimaryVariable convertPrimaryVariable ( const std::string& pcs_pv_string ); - -/** - * \brief Converts the given enum value into the appropriate string. - * @param pcs_pv primary variable described by the enum ProcessType - * @return string describing the process type - */ -std::string convertPrimaryVariableToString ( PrimaryVariable pcs_pv ); - -/// Returns a list of strings containing all entries in the PrimaryVariable enum. -const std::list<std::string> getAllPrimaryVariableNames(); - -enum DistributionType -{ - INVALID_DIS_TYPE = 0, - ANALYTICAL, // ST - AVERAGE, - CONSTANT, // IC, BC, ST - CONSTANT_GEO, - CONSTANT_NEUMANN, // ST - CRITICALDEPTH, // ST - DIRECT, // ST (directly on mesh nodes) - FUNCTION, - GRADIENT, // IC - GREEN_AMPT, // ST - RESTART, // IC - LINEAR, // BC, ST - LINEAR_NEUMANN, // ST - NODESCONSTANT, // IC (directly on mesh nodes) - NORMALDEPTH, // ST - POINT, // BC - PRECIPITATION, - SYSTEM_DEPENDENT, // ST - // make sure that this is always the last entry (important for iterating over the enum entries)! - DIS_END -}; - -/** - * \brief Converts the given string into the appropriate enum value. - * @param pcs_pv_string string describing the primary variable - * @return enum value describing the primary variable of the process - */ -DistributionType convertDisType(const std::string& dis_type_string); - -/** - * \brief Converts the given enum value into the appropriate string. - * @param pcs_pv primary variable described by the enum ProcessType - * @return string describing the process type - */ -std::string convertDisTypeToString(DistributionType dis_type); - -/// Returns a list of strings containing all entries in the DistributionType enum. -const std::list<std::string> getAllDistributionNames(); - -/** \brief Types of error method supported by OpenGeoSys. - * If you change this enum, make sure you apply the changes to - * the functions convertErrorMethod(), convertErrorMethodToString() - Non-Linear and Coupling options (see also CRFProcess::CalcIterationNODError()): - --> LMAX: max(|x1-x0|) -- Infinity norm: Local max error (across all elements) of solution vector delta (absolute error). Tolerance required for each primary variable. - --> ENORM: |x1-x0| -- Euclidian norm: Norm of the solution vector delta (absolute error). Norm taken over entire solution vector (all primary variables) and checked against a single tolerance. - --> EVNORM: |x1-x0| -- Euclidian varient norm: Norm of the solution vector delta (absolute error). Norm taken over solution vector of each primary variable, checked againes a tolerence specific to each variable. - --> ERNORM: |(x1-x0)/x0)| -- Euclidian Relative norm: Norm of the solution vector delta divided by the norm of the solution vector. A single tolerance applied to all primary variables. - --> BNORM: -- OGS classic treatment of newton methods. ENORM error tolerance plus RHS ("B") control. (note: other error methods (i.e. ENORM) will also work well for NEWTON scheme) - */ -enum ErrorMethod -{ - INVALID_ERROR_METHOD = 0, - LMAX, - ENORM, - EVNORM, - ERNORM, - BNORM -}; - -/** - * \brief Convert the given string into the appropriate enum value. - * @param pcs_type_string string describing an error method - * @return enum value describing error method - */ -ErrorMethod convertErrorMethod ( const std::string& error_method_string ); - -} // end namespace FiniteElement - -#endif //FEMENUMS_H diff --git a/OGS/GeoInfo.cpp b/OGS/GeoInfo.cpp deleted file mode 100644 index ea7bfdcea525c51260ca9b6ebdbedf6a0871f436..0000000000000000000000000000000000000000 --- a/OGS/GeoInfo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-06-18 - * \brief Implementation of the GeoInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -// STL -#include <limits> - -// FEM -#include "GeoInfo.h" - -GeoInfo::GeoInfo() : - _geo_type(GeoLib::GEOTYPE::INVALID), _geo_obj(NULL) -{} - -GeoInfo::GeoInfo(GeoLib::GEOTYPE geo_type, const GeoLib::GeoObject* geo_obj) : - _geo_type(geo_type), _geo_obj(geo_obj) -{} - -GeoInfo::~GeoInfo() -{} - -GeoLib::GEOTYPE GeoInfo::getGeomType () const -{ - return _geo_type; -} - -std::string GeoInfo::getGeomTypeAsString () const -{ - return GeoLib::convertGeoTypeToString(_geo_type); -} - -void GeoInfo::setGeoType (GeoLib::GEOTYPE geo_type) -{ - _geo_type = geo_type; -} - -const GeoLib::GeoObject* GeoInfo::getGeoObj () const -{ - return _geo_obj; -} - -void GeoInfo::setGeoObj (const GeoLib::GeoObject* geo_obj) -{ - _geo_obj = geo_obj; -} diff --git a/OGS/GeoInfo.h b/OGS/GeoInfo.h deleted file mode 100644 index 90549276573bf204e4a6f0bf6ba0778191aefd4e..0000000000000000000000000000000000000000 --- a/OGS/GeoInfo.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-06-18 - * \brief Definition of the GeoInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef GEOINFO_H_ -#define GEOINFO_H_ - -// GEO -#include "GeoLib/GeoObject.h" -#include "GeoLib/GeoType.h" - -/** - * \brief GeoInfo stores the type of the geometric entity and - * the index within the vector the geometric entity is - * managed. Possible geometric entities are documented in - * GeoType.h. - */ -class GeoInfo -{ -public: - /** - * standard constructor. You need to set the attributes via - * setGeoType() and setGeoObj()! - */ - GeoInfo (); - /** - * The constructor of a GeoInfo object initializes the - * attributes of the object. - * @param geo_type the type of the geometric entity. - * Possible geometric entities are documented in GeoType.h. - * @param geo_obj the pointer to an object of class GeoObject - */ - GeoInfo(GeoLib::GEOTYPE geo_type, const GeoLib::GeoObject* geo_obj = NULL); - /** - * virtual destructor - destroys the object - */ - virtual ~GeoInfo(); - - /** - * getter method for the geo type - * @sa enum GeoType - * @return the geo type - */ - GeoLib::GEOTYPE getGeomType () const; - - /** - * get the type as a string for log output - */ - std::string getGeomTypeAsString () const; - - /** - * getter for the pointer to the object - */ - const GeoLib::GeoObject* getGeoObj () const; - - /** - * setter for the geo type - * @sa enum GeoType - * @param geo_type type of the geometric entity - */ - void setGeoType (GeoLib::GEOTYPE geo_type); - /** - * setter for the pointer to the GeoObject object - * @param geo_obj an instance of class GeoObject - */ - void setGeoObj (const GeoLib::GeoObject* geo_obj); - -protected: - /** - * type of the geometric entity. @sa enum GeoType - */ - GeoLib::GEOTYPE _geo_type; - /** - * pointer to geometric object (GeoLib::Point, GeoLib::Polyline, GeoLib::Surface, ...) - */ - const GeoLib::GeoObject* _geo_obj; -}; -#endif /* GEOINFO_H_ */ diff --git a/OGS/InitialCondition.cpp b/OGS/InitialCondition.cpp deleted file mode 100644 index 6023c91806206715fef077ad12be7a2c5eff3e99..0000000000000000000000000000000000000000 --- a/OGS/InitialCondition.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Implementation of the InitialCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -/* -#include "InitialCondition.h" -#include "rf_ic_new.h" - -InitialCondition::InitialCondition(const CInitialCondition &ic, const std::string &geometry_name) - : FEMCondition(geometry_name, ic.getProcessType(), ic.getProcessPrimaryVariable(), - ic.getGeomType(), - (ic.getGeomType() == GeoLib::GEOTYPE::GEODOMAIN) ? "Domain" : ic.getGeoName(), - ic.getProcessDistributionType(), FEMCondition::INITIAL_CONDITION) -{ - if (this->getProcessDistributionType() == FiniteElement::CONSTANT) - this->setConstantDisValue(ic.getGeoNodeValue()); -} -*/ diff --git a/OGS/InitialCondition.h b/OGS/InitialCondition.h deleted file mode 100644 index 76c232ab0c4f376d4f55b60bb53cb62211390846..0000000000000000000000000000000000000000 --- a/OGS/InitialCondition.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Definition of the InitialCondition class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef INITIALCONDITION_H -#define INITIALCONDITION_H - -#include "FEMCondition.h" - -/** - * \brief Adapter class for handling boundary conditions in the user Interface - * \sa FEMCondition - */ -class InitialCondition : public FEMCondition -{ -public: - InitialCondition(const std::string &geometry_name) - : FEMCondition(geometry_name, FEMCondition::INITIAL_CONDITION) {}; - //InitialCondition(const CInitialCondition &ic, const std::string &geometry_name); - InitialCondition(const FEMCondition &cond) - : FEMCondition(cond, FEMCondition::INITIAL_CONDITION) {}; - ~InitialCondition() {} -}; - -#endif //INITIALCONDITION_H diff --git a/OGS/ProcessInfo.cpp b/OGS/ProcessInfo.cpp deleted file mode 100644 index cb4b50b29a32014514c85f99e012136a7825d408..0000000000000000000000000000000000000000 --- a/OGS/ProcessInfo.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-09-02 - * \brief Implementation of the ProcessInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include <ProcessInfo.h> - -ProcessInfo::ProcessInfo() : - _pcs_type (FiniteElement::INVALID_PROCESS), _pcs_pv (FiniteElement::INVALID_PV) -{} - -ProcessInfo::ProcessInfo (FiniteElement::ProcessType pcs_type, FiniteElement::PrimaryVariable pcs_pv) : - _pcs_type (pcs_type), _pcs_pv (pcs_pv) -{} - -void ProcessInfo::setProcessType (FiniteElement::ProcessType pcs_type) -{ - _pcs_type = pcs_type; -} - -void ProcessInfo::setProcessPrimaryVariable (FiniteElement::PrimaryVariable pcs_pv) -{ - _pcs_pv = pcs_pv; -} - -FiniteElement::ProcessType ProcessInfo::getProcessType () const -{ - return _pcs_type; -} - -FiniteElement::PrimaryVariable ProcessInfo::getProcessPrimaryVariable () const -{ - return _pcs_pv; -} - -ProcessInfo::~ProcessInfo() -{} diff --git a/OGS/ProcessInfo.h b/OGS/ProcessInfo.h deleted file mode 100644 index ddd66cc6b3b6888024cef4b08173e133b28a0c63..0000000000000000000000000000000000000000 --- a/OGS/ProcessInfo.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date 2010-09-02 - * \brief Definition of the ProcessInfo class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROCESSINFO_H_ -#define PROCESSINFO_H_ - -// FEM -#include "FEMEnums.h" - -/** - * \brief Class ProcessInfo stores the process type, - * an value for the primary variable of the process and - * a pointer to the process object. - */ -class ProcessInfo -{ -public: - /** - * Default constructor, initializes pcs_type with ProcessType::INVALID_PROCESS, - * pcs_pv with PrimaryVariable::INVALID_PV and - * the pointer to the process with NULL. The user should set the values - * with the appropriate set methods. - */ - ProcessInfo(); - - /** - * constructor initializing all attributes of the object with the given values - * @param pcs_type process type (\sa enum ProcessType) - * @param pcs_pv type of primary variable (\sa enum PrimaryVariable) - * @param pcs a pointer to the process - */ - ProcessInfo (FiniteElement::ProcessType pcs_type, FiniteElement::PrimaryVariable pcs_pv/* TODO6 , CRFProcess* pcs*/); - - /** - * Sets the process type. - * @param pcs_type the process type, for valid values see enum ProcessType - */ - void setProcessType (FiniteElement::ProcessType pcs_type); - - /** - * Sets the value for the primary variable - * @param pcs_pv value for primary variable, possible values are documented in enum PrimaryVariable - */ - void setProcessPrimaryVariable (FiniteElement::PrimaryVariable pcs_pv); - - /** - * Get the process type. - * @return the process type - */ - FiniteElement::ProcessType getProcessType () const; - - /** - * Get the primary variable of the process. - * @return the primary variable of the process - */ - FiniteElement::PrimaryVariable getProcessPrimaryVariable () const; - - virtual ~ProcessInfo(); - -protected: - /** - * process type, see enum ProcessType for valid values - */ - FiniteElement::ProcessType _pcs_type; - /** - * the primary variable of the process, see enum PrimaryVariable for valid values - */ - FiniteElement::PrimaryVariable _pcs_pv; -}; -#endif /* PROCESSINFO_H_ */ diff --git a/OGS/ProjectData.cpp b/OGS/ProjectData.cpp deleted file mode 100644 index f2714b0fc5800d2ffdda027344d34d200480d49b..0000000000000000000000000000000000000000 --- a/OGS/ProjectData.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-08-25 - * \brief Implementation of the project data class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "ProjectData.h" - -#include "Mesh.h" - -ProjectData::ProjectData() -: -#ifdef OGS_BUILD_GUI - _geoObjects(new GEOModels()) -#else - _geoObjects(new GeoLib::GEOObjects()) -#endif -{ -} - -ProjectData::~ProjectData() -{ - delete _geoObjects; - for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - delete *it; - size_t nCond (_cond_vec.size()); - for (size_t i = 0; i < nCond; i++) - delete _cond_vec[i]; -} - -void ProjectData::addMesh(MeshLib::Mesh* mesh) -{ - std::string name = mesh->getName(); - isUniqueMeshName(name); - mesh->setName(name); - _msh_vec.push_back(mesh); -} - -const MeshLib::Mesh* ProjectData::getMesh(const std::string &name) const -{ - for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - if (name.compare((*it)->getName()) == 0) - return *it; - return NULL; -} - -bool ProjectData::removeMesh(const std::string &name) -{ - for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - if (name.compare((*it)->getName()) == 0) - { - delete *it; - _msh_vec.erase(it); - return true; - } - return false; -} - -bool ProjectData::meshExists(const std::string &name) -{ - for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - if (name.compare((*it)->getName()) == 0) - return true; - return false; -} - -void ProjectData::addProcess(ProcessInfo* pcs) -{ - for (std::vector<ProcessInfo*>::const_iterator it = _pcs_vec.begin(); it != _pcs_vec.end(); ++it) - if ((*it)->getProcessType() == pcs->getProcessType()) - { - std::cout << "Error in ProjectData::addProcess() - " - << FiniteElement::convertProcessTypeToString(pcs->getProcessType()) << " process already exists." << std::endl; - } - - _pcs_vec.push_back(pcs); -} - -const ProcessInfo* ProjectData::getProcess(FiniteElement::ProcessType type) const -{ - for (std::vector<ProcessInfo*>::const_iterator it = _pcs_vec.begin(); it != _pcs_vec.end(); ++it) - if ((*it)->getProcessType() == type) - return *it; - - std::cout << "Error in ProjectData::getProcess() - No " - << FiniteElement::convertProcessTypeToString(type) << " process found..." << std::endl; - return NULL; -} - -bool ProjectData::removeProcess(FiniteElement::ProcessType type) -{ - for (std::vector<ProcessInfo*>::iterator it = _pcs_vec.begin(); it != _pcs_vec.end(); ++it) - if ((*it)->getProcessType() == type) - { - - delete *it; - _pcs_vec.erase(it); - return true; - } - - std::cout << "Error in ProjectData::removeProcess() - No " - << FiniteElement::convertProcessTypeToString(type) << " process found..." << std::endl; - return false; -} - -void ProjectData::addCondition(FEMCondition* cond) -{ - _cond_vec.push_back(cond); -} - -void ProjectData::addConditions(std::vector<FEMCondition*> conds) -{ - for (size_t i = 0; i < conds.size(); i++) - _cond_vec.push_back(conds[i]); -} - -const FEMCondition* ProjectData::getCondition(FiniteElement::ProcessType pcs_type, - const std::string &geo_name, - GeoLib::GEOTYPE type, - const std::string &cond_name) const -{ - for (std::vector<FEMCondition*>::const_iterator it = _cond_vec.begin(); it != _cond_vec.end(); ++it) - if ((*it)->getAssociatedGeometryName().compare(geo_name) == 0) - if ( ((*it)->getGeoName().compare(cond_name) == 0) && - ((*it)->getGeomType() == type) ) - return *it; - - std::cout << "Error in ProjectData::getCondition() - No condition found with name \"" - << cond_name << "\"..." << std::endl; - return nullptr; -} - -std::vector<FEMCondition*> ProjectData::getConditions(FiniteElement::ProcessType pcs_type, - std::string geo_name, - FEMCondition::CondType cond_type) const -{ - // if all - if (pcs_type == FiniteElement::INVALID_PROCESS && geo_name.empty() && cond_type == FEMCondition::UNSPECIFIED) - return _cond_vec; - - // else: filter according to parameters - std::vector<FEMCondition*> conds; - for (std::vector<FEMCondition*>::const_iterator it = _cond_vec.begin(); it != _cond_vec.end(); ++it) - { - if ( ((pcs_type == FiniteElement::INVALID_PROCESS) || (pcs_type == ((*it)->getProcessType()))) && - ((geo_name.empty() || ((*it)->getAssociatedGeometryName().compare(geo_name) == 0))) && - ((cond_type == FEMCondition::UNSPECIFIED) || ((*it)->getCondType() == cond_type)) ) - conds.push_back(*it); - } - - return conds; -} - -void ProjectData::removeConditions(FiniteElement::ProcessType pcs_type, std::string geo_name, FEMCondition::CondType cond_type) -{ - // if all - if (pcs_type == FiniteElement::INVALID_PROCESS && geo_name.empty() && cond_type == FEMCondition::UNSPECIFIED) - { - for (size_t i=0; i<_cond_vec.size(); i++) delete _cond_vec[i]; - return; - } - - // else: filter according to parameters - for (std::vector<FEMCondition*>::iterator it = _cond_vec.begin(); it != _cond_vec.end(); ) - { - if ( ((pcs_type == FiniteElement::INVALID_PROCESS) || (pcs_type == ((*it)->getProcessType()))) && - ((geo_name.empty() || ((*it)->getAssociatedGeometryName().compare(geo_name) == 0))) && - ((cond_type == FEMCondition::UNSPECIFIED) || ((*it)->getCondType() == cond_type)) ) - { - delete *it; - it = _cond_vec.erase(it); - } - else - ++it; - } -} - -bool ProjectData::removeCondition(const std::string &geo_name, - GeoLib::GEOTYPE type, - const std::string &cond_name) -{ - for (std::vector<FEMCondition*>::iterator it = _cond_vec.begin(); it != _cond_vec.end(); ++it) - { - if ((*it)->getAssociatedGeometryName().compare(geo_name) == 0) - if ( ((*it)->getGeoName().compare(cond_name) == 0) && - ((*it)->getGeomType() == type) ) - { - delete *it; - _cond_vec.erase(it); - return true; - } - } - std::cout << "Error in ProjectData::removeCondition() - No condition found with name \"" << - cond_name << "\"..." << std::endl; - return false; -} - -bool ProjectData::isUniqueMeshName(std::string &name) -{ - int count(0); - bool isUnique(false); - std::string cpName; - - while (!isUnique) - { - isUnique = true; - cpName = name; - - count++; - // If the original name already exists we start to add numbers to name for - // as long as it takes to make the name unique. - if (count > 1) - cpName = cpName + "-" + std::to_string(count); - - for (std::vector<MeshLib::Mesh*>::iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - if ( cpName.compare((*it)->getName()) == 0 ) - isUnique = false; - } - - // At this point cpName is a unique name and isUnique is true. - // If cpName is not the original name, "name" is changed and isUnique is set to false, - // indicating that a vector with the original name already exists. - if (count > 1) - { - isUnique = false; - name = cpName; - } - return isUnique; -} diff --git a/OGS/ProjectData.h b/OGS/ProjectData.h deleted file mode 100644 index 65fc31a95037eaf619cb4abb68028a03ea849457..0000000000000000000000000000000000000000 --- a/OGS/ProjectData.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2010-08-25 - * \brief - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROJECTDATA_H_ -#define PROJECTDATA_H_ - -#include "FEMCondition.h" -#include "FEMEnums.h" - -#ifdef OGS_BUILD_GUI -#include "Gui/DataView/GEOModels.h" -#else -#include "GEOObjects.h" -#endif - - -namespace MeshLib { - class Mesh; -} - -/** - * The ProjectData Object contains all the data needed for a certain project, i.e. all - * geometric data (stored in a GEOObjects-object), all the meshes, FEM Conditions (i.e. - * Boundary Conditions, Source Terms and Initial Conditions), etc. - * ProjectData does not administrate any of the objects, it is just a "container class" - * to store them all in one place. - * For each class of object stored in this container exists an add-, get- and remove-method. - * - * \sa GEOModels, FEMCondition - */ -class ProjectData -{ -public: - ProjectData(); - virtual ~ProjectData(); - - //** Geometry functionality **// - - // Returns the GEOObjects containing all points, polylines and surfaces - GeoLib::GEOObjects* getGEOObjects() { return _geoObjects; } - - //** Mesh functionality **// - - /// Adds a new mesh - virtual void addMesh(MeshLib::Mesh* mesh); - - /// Returns the mesh with the given name. - const MeshLib::Mesh* getMesh(const std::string &name) const; - - /// Returns all the meshes with their respective names - const std::vector<MeshLib::Mesh*>& getMeshObjects() const { return _msh_vec; } - - /// Removes the mesh with the given name. - virtual bool removeMesh(const std::string &name); - - /// Checks if the name of the mesh is already exists, if so it generates a unique name. - bool isUniqueMeshName(std::string &name); - - bool meshExists(const std::string &name); - - //** Process functionality **// - - /// Adds a new process - virtual void addProcess(ProcessInfo* pcs); - - /// Returns a process of the given type - const ProcessInfo* getProcess(FiniteElement::ProcessType type) const; - - /// Removes a process of the given type - virtual bool removeProcess(FiniteElement::ProcessType type); - - //** FEM Condition functionality **// - - /// Adds a new FEM Condition - virtual void addCondition(FEMCondition* cond); - - /// Adds new FEM Conditions - virtual void addConditions(std::vector<FEMCondition*> conds); - - /// Returns the FEM Condition set on a GeoObject with the given name and type from a certain geometry. - const FEMCondition* getCondition(FiniteElement::ProcessType pcs_type, - const std::string &geo_name, - GeoLib::GEOTYPE type, - const std::string &cond_name) const; - - /// Returns all FEM Conditions with the given type from a certain geometry. - std::vector<FEMCondition*> getConditions(FiniteElement::ProcessType pcs_type = FiniteElement::INVALID_PROCESS, - std::string geo_name = "", - FEMCondition::CondType type = FEMCondition::UNSPECIFIED) const; - - /// Removes the FEM Condition set on a GeoObject with the given name and type from a certain geometry. - virtual bool removeCondition(const std::string &geo_name, - GeoLib::GEOTYPE type, - const std::string &cond_name); - - /// Removes all FEM Conditions with the given type from the given process - virtual void removeConditions(FiniteElement::ProcessType pcs_type = FiniteElement::INVALID_PROCESS, - std::string geo_name = "", - FEMCondition::CondType cond_type = FEMCondition::UNSPECIFIED); - -private: -#ifdef OGS_BUILD_GUI - GEOModels *_geoObjects; -#else - GeoLib::GEOObjects *_geoObjects; -#endif - std::vector<MeshLib::Mesh*> _msh_vec; - std::vector<ProcessInfo*> _pcs_vec; - std::vector<FEMCondition*> _cond_vec; -}; - -#endif //PROJECTDATA_H_ diff --git a/OGS/SourceTerm.cpp b/OGS/SourceTerm.cpp deleted file mode 100644 index d84a603605c9cf2764e5b646985c11deaecd088c..0000000000000000000000000000000000000000 --- a/OGS/SourceTerm.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Implementation of the SourceTerm class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ -/* -#include "SourceTerm.h" -#include "rf_st_new.h" - -SourceTerm::SourceTerm(const CSourceTerm &st, const std::string &geometry_name) - : FEMCondition(geometry_name, st.getProcessType(), st.getProcessPrimaryVariable(), - st.getGeomType(), st.getGeoName(), - st.getProcessDistributionType(), FEMCondition::SOURCE_TERM) -{ - if (this->getProcessDistributionType() == FiniteElement::CONSTANT || - this->getProcessDistributionType() == FiniteElement::CONSTANT_NEUMANN) - this->setConstantDisValue(st.getGeoNodeValue()); - else if (this->getProcessDistributionType() == FiniteElement::LINEAR || - this->getProcessDistributionType() == FiniteElement::LINEAR_NEUMANN) - { - const std::vector<int> st_nodes(st.getPointsWithDistribedST()); - std::vector<size_t> dis_nodes(st_nodes.size()); - for (size_t i=0; i<dis_nodes.size(); i++) dis_nodes[i] = static_cast<size_t>(st_nodes[i]); - this->setDisValues(dis_nodes, st.getDistribedST()); - } - else if (this->getProcessDistributionType() == FiniteElement::DIRECT) - { - //this->_direct_file_name = st.fname; - } - else - std::cout << "Error in SourceTerm() - Unknown Process Distribution Type \"" << - FiniteElement::convertDisTypeToString(st.getProcessDistributionType()) << - "\"..." << - std::endl; -} - -// Legacy function (only required for ascii st-files): reads values for 'direct' source terms -void SourceTerm::getDirectNodeValues(const std::string &filename, - std::vector< std::pair<size_t, double> > &node_values) -{ - std::ifstream in(filename.c_str()); - if (!in.is_open()) - { - std::cout << "Error in getNodeValues() - Could not find file for direct node values..." << std::endl; - return; - } - - std::stringstream str_in; - std::string line(""); - size_t idx(0); - double val(0); - - while ( getline(in, line) ) - { - if (line.find("#STOP") != std::string::npos) - return; - str_in << line; - str_in >> idx >> val; - node_values.push_back(std::pair<size_t, double>(idx, val)); - str_in.clear(); - } -} -*/ \ No newline at end of file diff --git a/OGS/SourceTerm.h b/OGS/SourceTerm.h deleted file mode 100644 index 75b5734411146023b1bff5796a9360113722abba..0000000000000000000000000000000000000000 --- a/OGS/SourceTerm.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2011-08-30 - * \brief Definition of the SourceTerm class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef SOURCETERM_H -#define SOURCETERM_H - -#include "FEMCondition.h" - -/** - * \brief Adapter class for handling boundary conditions in the user Interface - * \sa FEMCondition - */ -class SourceTerm : public FEMCondition -{ -public: - SourceTerm(const std::string &geometry_name) - : FEMCondition(geometry_name, FEMCondition::SOURCE_TERM), _tim_type(0) {} - //SourceTerm(const CSourceTerm &st, const std::string &geometry_name); - SourceTerm(const FEMCondition &cond) - : FEMCondition(cond, FEMCondition::SOURCE_TERM) {}; - ~SourceTerm() {} - - std::size_t getTimType() const {return _tim_type; } - void setTimType(std::size_t value) { _tim_type = value; } - - // Legacy function (only required for ascii st-files): reads values for 'direct' source terms - static void getDirectNodeValues(const std::string &filename, - std::vector< std::pair<std::size_t, double> > &nodes_values); - -private: - std::size_t _tim_type; -}; - -#endif //SOURCETERM_H diff --git a/ProcessLib/BoundaryCondition.h b/ProcessLib/BoundaryCondition.h new file mode 100644 index 0000000000000000000000000000000000000000..27a2d551f0e9beb5e34b9ebc4bb0f79b9c059924 --- /dev/null +++ b/ProcessLib/BoundaryCondition.h @@ -0,0 +1,62 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROCESS_LIB_BOUNDARY_CONDITION_H_ +#define PROCESS_LIB_BOUNDARY_CONDITION_H_ + +#include <boost/property_tree/ptree.hpp> +#include "logog/include/logog.hpp" + +namespace GeoLib +{ + class GeoObject; +} + +namespace ProcessLib +{ + +class BoundaryCondition +{ +public: + BoundaryCondition(GeoLib::GeoObject const* const geometry) + : _geometry(geometry) + { } + + virtual ~BoundaryCondition() = default; + +private: + GeoLib::GeoObject const* const _geometry; +}; + +/// The UniformDirichletBoundaryCondition class describes a constant in space +/// and time Dirichlet boundary condition. +/// The expected parameter in the passed configuration is "value" which, when +/// not present defaults to zero. +class UniformDirichletBoundaryCondition : public BoundaryCondition +{ + using ConfigTree = boost::property_tree::ptree; +public: + UniformDirichletBoundaryCondition(GeoLib::GeoObject const* const geometry, + ConfigTree const& config) + : BoundaryCondition(geometry) + { + DBUG("Constructing UniformDirichletBoundaryCondition from config."); + + _value = config.get<double>("value", 0); + DBUG("Using value %g", _value); + } + +private: + double _value; +}; + + +} // namespace ProcessLib + +#endif // PROCESS_LIB_BOUNDARY_CONDITION_H_ diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..600bf3504526eeecca8ad57267025994a2878d4a --- /dev/null +++ b/ProcessLib/CMakeLists.txt @@ -0,0 +1,9 @@ +# Source files +GET_SOURCE_FILES(SOURCES) + +ADD_LIBRARY(ProcessLib STATIC ${SOURCES}) + +TARGET_LINK_LIBRARIES( ProcessLib + AssemblerLib + MeshLib +) diff --git a/ProcessLib/GroundwaterFlow.h b/ProcessLib/GroundwaterFlow.h new file mode 100644 index 0000000000000000000000000000000000000000..1c79d7e3566f6cfba4b351b69130759d0096b911 --- /dev/null +++ b/ProcessLib/GroundwaterFlow.h @@ -0,0 +1,66 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROCESS_LIB_GROUNDWATERFLOW_H_ +#define PROCESS_LIB_GROUNDWATERFLOW_H_ + +#include <boost/property_tree/ptree.hpp> +#include "logog/include/logog.hpp" + +#include "MeshLib/Mesh.h" +#include "ProcessVariable.h" + +namespace ProcessLib +{ + +class GroundwaterFlowProcess : public Process +{ + using ConfigTree = boost::property_tree::ptree; + +public: + GroundwaterFlowProcess(MeshLib::Mesh const& mesh, + std::vector<ProcessVariable> const& variables, + ConfigTree const& config) + : Process(mesh, 1) + { + DBUG("Create GroundwaterFlowProcess."); + + // Find the corresponding process variable. + std::string const name = config.get<std::string>("process_variable"); + + auto const& variable = std::find_if(variables.cbegin(), variables.cend(), + [&name](ProcessVariable const& v) { + return v.getName() == name; + }); + + if (variable == variables.end()) + ERR("Expected process variable \'%s\' not found in provided variables list.", + name.c_str()); + + DBUG("Associate hydraulic_head with process variable \'%s\'.", + name.c_str()); + _hydraulic_head = &*variable; + + } + + void initialize() + { + } + + ~GroundwaterFlowProcess() + { + } + +private: + ProcessVariable const* _hydraulic_head = nullptr; +}; + +} // namespace ProcessLib + +#endif // PROCESS_LIB_GROUNDWATERFLOW_H_ diff --git a/ProcessLib/InitialCondition.h b/ProcessLib/InitialCondition.h new file mode 100644 index 0000000000000000000000000000000000000000..ca911631a111796fe368e699887feb5dce40536d --- /dev/null +++ b/ProcessLib/InitialCondition.h @@ -0,0 +1,47 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROCESS_LIB_INITIAL_CONDITION_H_ +#define PROCESS_LIB_INITIAL_CONDITION_H_ + +#include <boost/property_tree/ptree.hpp> +#include "logog/include/logog.hpp" + +#include "MeshLib/Mesh.h" + +namespace ProcessLib +{ + +class InitialCondition +{ +public: + virtual ~InitialCondition() = default; +}; + + +class UniformInitialCondition : public InitialCondition +{ + using ConfigTree = boost::property_tree::ptree; +public: + UniformInitialCondition(ConfigTree const& config) + { + DBUG("Constructing Uniform initial condition"); + + _value = config.get<double>("value", 0); + DBUG("Read value %g", _value); + } + +private: + double _value; +}; + + +} // namespace ProcessLib + +#endif // PROCESS_LIB_INITIAL_CONDITION_H_ diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h new file mode 100644 index 0000000000000000000000000000000000000000..b76b93d2d9e20aa1c357f924f948cdb0d6878dc3 --- /dev/null +++ b/ProcessLib/Process.h @@ -0,0 +1,41 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROCESS_LIB_PROCESS_H_ +#define PROCESS_LIB_PROCESS_H_ + +#include "MeshLib/Mesh.h" + +namespace ProcessLib +{ + +class Process +{ +public: + Process(MeshLib::Mesh const& mesh, std::size_t const numberOfNodeComponents) + : _mesh(mesh), _numberOfNodeComponents(numberOfNodeComponents) + { } + + virtual ~Process() = default; + + virtual void initialize() = 0; + +protected: + MeshLib::Mesh const& _mesh; + std::size_t const _numberOfNodeComponents; +}; + +} // namespace ProcessLib + +// +// Include all known processes here. +// +#include "GroundwaterFlow.h" + +#endif // PROCESS_LIB_PROCESS_H_ diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5b76a611625b9de5ee53ddf1aacae29fa569b914 --- /dev/null +++ b/ProcessLib/ProcessVariable.cpp @@ -0,0 +1,108 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include <boost/property_tree/ptree.hpp> +#include "logog/include/logog.hpp" + +#include "GeoLib/GEOObjects.h" +#include "MeshLib/Mesh.h" + +#include "BoundaryCondition.h" +#include "InitialCondition.h" + +#include "ProcessVariable.h" + +namespace ProcessLib +{ + +ProcessVariable::ProcessVariable( + ConfigTree const& config, + MeshLib::Mesh const& mesh, + GeoLib::GEOObjects const& geometries) + : _name(config.get<std::string>("name")), + _mesh(mesh) +{ + DBUG("Constructing process variable %s", this->_name.c_str()); + + // Initial condition + { + auto const& ic_config = config.find("initial_condition"); + if (ic_config == config.not_found()) + INFO("No initial condition found."); + + + std::string const type = + config.get<std::string>("initial_condition.type"); + if (type == "Uniform") + { + _initial_condition = + new UniformInitialCondition(ic_config->second); + } + else + { + ERR("Unknown type of the initial condition."); + } + } + + // Boundary conditions + { + auto const& bcs_config = config.find("boundary_conditions"); + if (bcs_config == config.not_found()) + INFO("No boundary conditions found."); + + for (auto const& bc_iterator : bcs_config->second) + { + ConfigTree const& bc_config = bc_iterator.second; + + // Find corresponding GeoObject + std::string const geometrical_set_name = + bc_config.get<std::string>("geometrical_set"); + std::string const geometry_name = + bc_config.get<std::string>("geometry"); + + // TODO Currently only Polylines are supported for the boundary + // conditions. + GeoLib::GeoObject const* const geometry = geometries.getGeoObject( + geometrical_set_name, GeoLib::GEOTYPE::POLYLINE, geometry_name); + DBUG("Found geometry type \"%s\"", + GeoLib::convertGeoTypeToString(geometry->getGeoType()).c_str()); + + // Construct type dependent boundary condition + std::string const type = bc_config.get<std::string>("type"); + + if (type == "UniformDirichlet") + { + _boundary_conditions.emplace_back( + new UniformDirichletBoundaryCondition( + geometry, bc_config)); + } + else + { + ERR("Unknown type \'%s\' of the boundary condition.", + type.c_str()); + } + } + + } +} + +ProcessVariable::~ProcessVariable() +{ + delete _initial_condition; + + for(auto p : _boundary_conditions) + delete p; +} + +std::string const& ProcessVariable::getName() const +{ + return _name; +} + +} // namespace ProcessLib diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h new file mode 100644 index 0000000000000000000000000000000000000000..2db83e209d8819a6afc6ffb00691d392ea2d75f0 --- /dev/null +++ b/ProcessLib/ProcessVariable.h @@ -0,0 +1,49 @@ +/** + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef PROCESS_LIB_PROCESS_VARIABLE_H_ +#define PROCESS_LIB_PROCESS_VARIABLE_H_ + +#include <boost/property_tree/ptree.hpp> + +#include "GeoLib/GEOObjects.h" +#include "MeshLib/Mesh.h" + +namespace ProcessLib +{ + class BoundaryCondition; + class InitialCondition; +} + +namespace ProcessLib +{ + +/// A named process variable. Its properties includes the mesh, and the initial +/// and boundary conditions. +class ProcessVariable +{ + using ConfigTree = boost::property_tree::ptree; +public: + ProcessVariable(ConfigTree const& config, MeshLib::Mesh const& mesh, + GeoLib::GEOObjects const& geometries); + + ~ProcessVariable(); + + std::string const& getName() const; + +private: + std::string const _name; + MeshLib::Mesh const& _mesh; + InitialCondition* _initial_condition; + std::vector<BoundaryCondition*> _boundary_conditions; +}; + +} // namespace ProcessLib + +#endif // PROCESS_LIB_PROCESS_VARIABLE_H_ diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0e3b5c0eae842f60e1db2db9abdb0484a64885e7..7c15e9837b31e5bbca90465f4ace8af5b5fa594f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -44,6 +44,7 @@ ENDIF() TARGET_LINK_LIBRARIES(testrunner GTest + ApplicationsLib AssemblerLib BaseLib FileIO @@ -52,7 +53,6 @@ TARGET_LINK_LIBRARIES(testrunner MeshLib MeshGeoToolsLib NumLib - OgsLib logog ${BOOST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} diff --git a/Tests/FileIO/TestBoostXmlCndInterface.cpp b/Tests/FileIO/TestBoostXmlCndInterface.cpp deleted file mode 100644 index 062d2ccd623d4345e410144613d8ba050078b5f6..0000000000000000000000000000000000000000 --- a/Tests/FileIO/TestBoostXmlCndInterface.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/** - * \file TestBoostXmlCndInterface.cpp - * \date 2014-02-07 - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - * - */ - -#include <boost/filesystem.hpp> - -#include "gtest/gtest.h" - -#include "BaseLib/BuildInfo.h" - -// FileIO -#include "XmlIO/Qt/XmlCndInterface.h" -#include "XmlIO/Boost/BoostXmlCndInterface.h" - -// OgsLib -#include "OGS/ProjectData.h" -#include "OGS/BoundaryCondition.h" -#include "OGS/FEMEnums.h" - -TEST(FileIO, TestBoostXmlCndInterfaceUsingBoundaryCondition) -{ - // setup test data - std::string geometry_name("GeometryForBC"); - const std::string bc_pnt_name("bc_pnt"); - GeoLib::Point *bc_pnt(new GeoLib::Point(0.0, 0.1, 0.2)); - - std::vector<GeoLib::Point*> *pnts = new std::vector<GeoLib::Point*>; - pnts->push_back(bc_pnt); - - std::map<std::string, std::size_t>* pnt_names - = new std::map<std::string, std::size_t>; - pnt_names->insert(std::pair<std::string, std::size_t>(bc_pnt_name, 0)); - - ProjectData project_data; - GeoLib::GEOObjects &geo_objects(*project_data.getGEOObjects()); - - geo_objects.addPointVec(pnts, geometry_name, pnt_names); - - // fill BoundaryCondition data structure - BoundaryCondition *bc(new BoundaryCondition(geometry_name)); - bc->initGeometricAttributes(geometry_name, GeoLib::GEOTYPE::POINT, - bc_pnt_name, geo_objects); - // set process info - bc->setProcessType(FiniteElement::ProcessType::GROUNDWATER_FLOW); - bc->setProcessPrimaryVariable(FiniteElement::PrimaryVariable::HEAD); - // set distribution info - bc->setProcessDistributionType(FiniteElement::DistributionType::CONSTANT); - bc->setConstantDisValue(10.0); - - project_data.addCondition(bc); - - // write bc to file - const std::string local_path("XmlCndInterfaceTestFile.cnd"); - std::string fname(BaseLib::BuildInfo::tests_tmp_path + local_path); - - FileIO::XmlCndInterface xml(project_data); - xml.setNameForExport(geometry_name); - int result_out = xml.writeToFile(fname); - ASSERT_EQ(result_out, 1); - - // read bc from file using BoostXmlCndInterface - FileIO::BoostXmlCndInterface cnd_interface(project_data); - int result = cnd_interface.readFile(fname); - - //boost::filesystem::remove(fname); - - ASSERT_EQ(result, 1); - // check the number of conditions in the vector - std::vector<FEMCondition*> conds(project_data.getConditions()); - ASSERT_EQ(2u, conds.size()); - // compare the associated geometry and the names - ASSERT_EQ(conds[0]->getAssociatedGeometryName().compare( - conds[1]->getAssociatedGeometryName() - ), 0); - ASSERT_EQ(conds[0]->getGeoName().compare(conds[1]->getGeoName()), 0); - - // fetch and compare geometries - GeoLib::GeoObject * geo_obj_0 ( - const_cast<GeoLib::GeoObject*>( - (geo_objects.getGeoObject( - conds[0]->getAssociatedGeometryName(), - GeoLib::GEOTYPE::POINT, - conds[0]->getGeoName()) - ) - ) - ); - GeoLib::GeoObject * geo_obj_1 ( - const_cast<GeoLib::GeoObject*>( - (geo_objects.getGeoObject( - conds[1]->getAssociatedGeometryName(), - GeoLib::GEOTYPE::POINT, - conds[1]->getGeoName()) - ) - ) - ); - GeoLib::Point &pnt_0(* static_cast<GeoLib::Point *>(geo_obj_0)); - GeoLib::Point &pnt_1(* static_cast<GeoLib::Point *>(geo_obj_1)); - ASSERT_NEAR(pnt_0[0], pnt_1[0], std::numeric_limits<double>::epsilon()); - ASSERT_NEAR(pnt_0[1], pnt_1[1], std::numeric_limits<double>::epsilon()); - ASSERT_NEAR(pnt_0[2], pnt_1[2], std::numeric_limits<double>::epsilon()); - - // compare process related information - ASSERT_EQ(conds[0]->getProcessType(), conds[1]->getProcessType()); - ASSERT_EQ(conds[0]->getProcessPrimaryVariable(), conds[1]->getProcessPrimaryVariable()); - - // compare distribution information - ASSERT_EQ(conds[0]->getProcessDistributionType(), - conds[1]->getProcessDistributionType()); - ASSERT_EQ(conds[0]->getDisValues().size(), conds[1]->getDisValues().size()); - ASSERT_NEAR(conds[0]->getDisValues()[0], conds[1]->getDisValues()[0], std::numeric_limits<double>::epsilon()); -} diff --git a/Tests/FileIO/TestXmlGmlReader.cpp b/Tests/FileIO/TestXmlGmlReader.cpp index 6262d8589924cf9adb1f78bd2d684facab272003..9dfa12496d3466fd7972eb439e9a0b815831a97a 100644 --- a/Tests/FileIO/TestXmlGmlReader.cpp +++ b/Tests/FileIO/TestXmlGmlReader.cpp @@ -20,8 +20,7 @@ // FileIO #include "XmlIO/Qt/XmlGmlInterface.h" -// OgsLib -#include "OGS/ProjectData.h" +#include "Applications/ProjectData.h" // GeoLib #include "Polyline.h" diff --git a/Utils/FileConverter/CMakeLists.txt b/Utils/FileConverter/CMakeLists.txt index 2ba98630f99cf12399df911b306d76502918f57e..e45789b910a62e04def6eec3174c528192adbcc5 100644 --- a/Utils/FileConverter/CMakeLists.txt +++ b/Utils/FileConverter/CMakeLists.txt @@ -17,7 +17,6 @@ IF (QT4_FOUND) FileIO GeoLib BaseLib - OgsLib shp ${QT_LIBRARIES} ) @@ -26,17 +25,17 @@ IF (QT4_FOUND) ADD_EXECUTABLE (generateBCandGLI generateBCandGLI.cpp ) TARGET_LINK_LIBRARIES (generateBCandGLI + ApplicationsLib FileIO GeoLib - OgsLib ${QT_LIBRARIES} ) ADD_EXECUTABLE (generateBCFromPolyline generateBCFromPolyline.cpp ) TARGET_LINK_LIBRARIES (generateBCFromPolyline + ApplicationsLib FileIO GeoLib - OgsLib ${QT_LIBRARIES} ) diff --git a/Utils/FileConverter/generateBCFromPolyline.cpp b/Utils/FileConverter/generateBCFromPolyline.cpp index 198b04df6327784ce68e989f3ad5d3f7d51d45e6..b4ef4c9d6951b20cc2eb3556ec32327a56b02ee8 100644 --- a/Utils/FileConverter/generateBCFromPolyline.cpp +++ b/Utils/FileConverter/generateBCFromPolyline.cpp @@ -21,7 +21,7 @@ #include "PolylineVec.h" // OGS -#include "OGS/ProjectData.h" +#include "Applications/ProjectData.h" // FileIO #include "XmlIO/Qt/XmlGmlInterface.h" diff --git a/Utils/FileConverter/generateBCandGLI.cpp b/Utils/FileConverter/generateBCandGLI.cpp index 5832fc800d9bcee18785d3f83ea13dcb8e9d78b3..8c266c4027af178ad2c5e77990252b67603241a4 100644 --- a/Utils/FileConverter/generateBCandGLI.cpp +++ b/Utils/FileConverter/generateBCandGLI.cpp @@ -23,8 +23,7 @@ #include "GEOObjects.h" #include "SurfaceVec.h" -// OgsLib -#include "OGS/ProjectData.h" +#include "Applications/ProjectData.h" // FileIO #include "XmlIO/Qt/XmlGmlInterface.h"