From 9a47f598b768eded74d57ae289232cd1abeda65d Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 4 Jan 2019 00:10:03 +0100 Subject: [PATCH] Remove unneeded Undefined property. The nullptr is probably sufficient in the PropertyArray, which is an array of pointers, for the property to be undefined. --- MaterialLib/MPL/Component.cpp | 8 ----- MaterialLib/MPL/Medium.cpp | 10 ------- MaterialLib/MPL/Medium.h | 5 ++++ MaterialLib/MPL/Phase.cpp | 7 ----- MaterialLib/MPL/Phase.h | 6 ++++ MaterialLib/MPL/Properties/Properties.h | 17 ----------- MaterialLib/MPL/Properties/Undefined.cpp | 38 ------------------------ MaterialLib/MPL/Properties/Undefined.h | 31 ------------------- 8 files changed, 11 insertions(+), 111 deletions(-) delete mode 100644 MaterialLib/MPL/Properties/Undefined.cpp delete mode 100644 MaterialLib/MPL/Properties/Undefined.h diff --git a/MaterialLib/MPL/Component.cpp b/MaterialLib/MPL/Component.cpp index 91bee1296cb..418af9cef82 100644 --- a/MaterialLib/MPL/Component.cpp +++ b/MaterialLib/MPL/Component.cpp @@ -19,19 +19,11 @@ namespace MaterialPropertyLib { Component::Component() { - // This method initializes the component property array with constant - // functions of value zero. - _properties = createDefaultUndefinedProperties(); - // Some properties can be initialized by other default properties: _properties[name] = std::make_unique("no_name"); } Component::Component(std::string const& component_name) { - // This method initializes the component property array with constant - // functions of value zero. - _properties = createDefaultUndefinedProperties(); - // Some properties can be initialized by other default properties: _properties[name] = std::make_unique(component_name); } diff --git a/MaterialLib/MPL/Medium.cpp b/MaterialLib/MPL/Medium.cpp index 26a7bf6e9d7..3a665b99946 100644 --- a/MaterialLib/MPL/Medium.cpp +++ b/MaterialLib/MPL/Medium.cpp @@ -26,16 +26,6 @@ namespace MaterialPropertyLib { Medium::Medium(BaseLib::ConfigTree const& config) { - // Default properties are initialized in the first place, such that - // user-defined properties overwrite those defaults. - // - // A method that creates the default properties of the medium. Currently, - // these defaults is the volume fraction average. - // - // Most properties are fine with the volume fraction average, but - // special-defaults are allowed as well... - _properties = createDefaultUndefinedProperties(); - // A name of a medium is entirely optional and has no effects // other than a small gain of clarity in case several media // should be defined. diff --git a/MaterialLib/MPL/Medium.h b/MaterialLib/MPL/Medium.h index 97ff2f2ac00..88903193975 100644 --- a/MaterialLib/MPL/Medium.h +++ b/MaterialLib/MPL/Medium.h @@ -30,6 +30,11 @@ class Medium /// The vector that holds the phases. std::vector> _phases; /// The array that holds the medium properties. + /// + /// Currently, these defaults is the volume fraction average. + /// + /// Most properties are fine with the volume fraction average, but + /// special-defaults are allowed as well... PropertyArray _properties; public: diff --git a/MaterialLib/MPL/Phase.cpp b/MaterialLib/MPL/Phase.cpp index 7772d797fdf..8fc33774749 100644 --- a/MaterialLib/MPL/Phase.cpp +++ b/MaterialLib/MPL/Phase.cpp @@ -21,13 +21,6 @@ namespace MaterialPropertyLib { Phase::Phase(std::string const& phase_name) { - // Here, all for all properties listed in the Properties enumerator are - // initialized by mole average functions of value zero. However, - // 'special-default' properties are allowed to be set. - // - // After this, other special properties can be set as exceptional defaults. - _properties = createDefaultUndefinedProperties(); - std::array allowed_phase_names = { {"solid", "aqueous liquid", "non-aqueous liquid", "gas"}}; diff --git a/MaterialLib/MPL/Phase.h b/MaterialLib/MPL/Phase.h index 4b347d5adc5..fc24c104215 100644 --- a/MaterialLib/MPL/Phase.h +++ b/MaterialLib/MPL/Phase.h @@ -29,6 +29,12 @@ class Phase final { private: std::vector> _components; + + /// Here, all for all properties listed in the Properties enumerator are + /// initialized by mole average functions of value zero. However, + /// 'special-default' properties are allowed to be set. + /// + /// After this, other special properties can be set as exceptional defaults. PropertyArray _properties; public: diff --git a/MaterialLib/MPL/Properties/Properties.h b/MaterialLib/MPL/Properties/Properties.h index 556c76f7bd0..f6475ca31b5 100644 --- a/MaterialLib/MPL/Properties/Properties.h +++ b/MaterialLib/MPL/Properties/Properties.h @@ -12,21 +12,4 @@ */ #pragma once -#include #include "Constant.h" -#include "Undefined.h" - -namespace MaterialPropertyLib -{ -inline PropertyArray createDefaultUndefinedProperties() -{ - PropertyArray properties; - for (std::size_t i = 0; i < numberOfProperties; ++i) - { - properties[i] = - std::make_unique(static_cast(i)); - } - - return properties; -} -} // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Properties/Undefined.cpp b/MaterialLib/MPL/Properties/Undefined.cpp deleted file mode 100644 index 4c2fe085e76..00000000000 --- a/MaterialLib/MPL/Properties/Undefined.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - * \file - * \author Norbert Grunwald - * \date July 3rd, 2018 - * - * \copyright - * Copyright (c) 2012-2018, 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 "Undefined.h" - -#include -#include "MaterialLib/MPL/Enums.h" - -namespace MaterialPropertyLib -{ -Undefined::Undefined(PropertyType const& p) : _property_type{p} {} - -PropertyDataType Undefined::value() const -{ - std::string const& property = property_enum_to_string[_property_type]; - - OGS_FATAL( - "The property '%s' (property-enum no. %i in " - "MaterialLib/MPL/mpEnums.h) was requested, but is not defined in the " - "project file.", - property.c_str(), static_cast(_property_type)); -} - -PropertyDataType Undefined::value(VariableArray const& /*variables*/) const -{ - return value(); -} -} // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Properties/Undefined.h b/MaterialLib/MPL/Properties/Undefined.h deleted file mode 100644 index 33c3fb65709..00000000000 --- a/MaterialLib/MPL/Properties/Undefined.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * \file - * \author Norbert Grunwald - * \date July 3rd, 2018 - * - * \copyright - * Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ -#pragma once - -#include "MaterialLib/MPL/Property.h" - -namespace MaterialPropertyLib -{ -/// The constant property class. This property simply retrieves the stored -/// constant value. It accepts all datatypes defined in PropertyDataType. -class Undefined final : public Property -{ -private: - PropertyType _property_type; - -public: - explicit Undefined(PropertyType const& p); - PropertyDataType value() const override; - PropertyDataType value(VariableArray const& /*variables*/) const override; -}; -} // namespace MaterialPropertyLib