8000 General Parameter interface. by chleh · Pull Request #1357 · ufz/ogs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

General Parameter interface. #1357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions Applications/ApplicationsLib/ProjectData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config,
//! \ogs_file_param{prj__curves}
parseCurves(project_config.getConfigSubtreeOptional("curves"));

//! \ogs_file_param{prj__process_variables}
parseProcessVariables(project_config.getConfigSubtree("process_variables"));

//! \ogs_file_param{prj__parameters}
parseParameters(project_config.getConfigSubtree("parameters"));

//! \ogs_file_param{prj__process_variables}
parseProcessVariables(project_config.getConfigSubtree("process_variables"));

//! \ogs_file_param{prj__processes}
parseProcesses(project_config.getConfigSubtree("processes"));

Expand Down Expand Up @@ -273,7 +273,7 @@ void ProjectData::parseProcessVariables(
{
// TODO Extend to referenced meshes.
_process_variables.emplace_back(var_config, *_mesh_vec[0],
*_geoObjects);
*_geoObjects, _parameters);
}
}

Expand All @@ -286,30 +286,8 @@ void ProjectData::parseParameters(BaseLib::ConfigTree const& parameters_config)
//! \ogs_file_param{prj__parameters__parameter}
parameters_config.getConfigSubtreeList("parameter"))
{
//! \ogs_file_param{parameter__name}
auto name = parameter_config.getConfigParameter<std::string>("name");
//! \ogs_file_param{parameter__type}
auto type = parameter_config.peekConfigParameter<std::string>("type");

// Create parameter based on the provided type.
if (type == "Constant")
{
INFO("ConstantParameter: %s.", name.c_str());
_parameters.push_back(createConstParameter(parameter_config));
_parameters.back()->name = name;
}
else if (type == "MeshProperty")
{
INFO("MeshPropertyParameter: %s", name.c_str());
_parameters.push_back(
createMeshPropertyParameter(parameter_config, *_mesh_vec[0]));
_parameters.back()->name = name;
}
else
{
OGS_FATAL("Cannot construct property of given type \'%s\'.",
type.c_str());
}
_parameters.push_back(
ProcessLib::createParameter(parameter_config, _mesh_vec));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Applications/ApplicationsLib/ProjectData.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "GeoLib/GEOObjects.h"

#include "ProcessLib/Output.h"
#include "ProcessLib/Parameter.h"
#include "ProcessLib/Parameter/Parameter.h"
#include "ProcessLib/Process.h"
#include "ProcessLib/ProcessVariable.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void UncoupledProcessesTimeLoop::setInitialConditions(
ode_sys.getMatrixSpecifications()));

auto& x0 = *_process_solutions[pcs_idx];
pcs.setInitialConditions(x0);
pcs.setInitialConditions(t0, x0);
MathLib::LinAlg::finalizeAssembly(x0);

time_disc.setInitialState(t0, x0); // push IC
Expand Down
9 changes: 9 additions & 0 deletions MeshLib/PropertyVector.h
6D4E
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ friend class Properties;
return std::vector<PROP_VAL_TYPE>::size() / _n_components;
}

//! Returns the value for the given component stored in the given tuple.
PROP_VAL_TYPE const& getComponent(std::size_t tuple_index,
std::size_t component) const
{
assert(component < _n_components);
assert(tuple_index < getNumberOfTuples());
return this->operator[](tuple_index* getNumberOfTuples() + component);
}

PropertyVectorBase* clone(std::vector<std::size_t> const& exclude_positions) const
{
PropertyVector<PROP_VAL_TYPE> *t(new PropertyVector<PROP_VAL_TYPE>(_property_name,
Expand Down
3 changes: 3 additions & 0 deletions ProcessLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ APPEND_SOURCE_FILES(SOURCES)
add_subdirectory(BoundaryCondition)
APPEND_SOURCE_FILES(SOURCES BoundaryCondition)

add_subdirectory(Parameter)
APPEND_SOURCE_FILES(SOURCES Parameter)

add_subdirectory(GroundwaterFlow)
APPEND_SOURCE_FILES(SOURCES GroundwaterFlow)

Expand Down
6 changes: 3 additions & 3 deletions ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "CreateGroundwaterFlowProcess.h"

#include "ProcessLib/Utils/ParseSecondaryVariables.h"
#include "ProcessLib/Utils/ProcessUtils.h"
#include "GroundwaterFlowProcess.h"
#include "GroundwaterFlowProcessData.h"

Expand Down Expand Up @@ -38,12 +39,11 @@ std::unique_ptr<Process> createGroundwaterFlowProcess(
"process_variable"});

// Hydraulic conductivity parameter.
auto& hydraulic_conductivity = findParameter<double,
MeshLib::Element const&>(
auto& hydraulic_conductivity = findParameter<double>(
config,
//! \ogs_file_param_special{process__GROUNDWATER_FLOW__hydraulic_conductivity}
"hydraulic_conductivity",
parameters);
parameters, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 == The parameter has one component.


DBUG("Use \'%s\' as hydraulic conductivity parameter.",
hydraulic_conductivity.name.c_str());
Expand Down
12 changes: 8 additions & 4 deletions ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "NumLib/Fem/ShapeMatrixPolicy.h"
#include "ProcessLib/LocalAssemblerInterface.h"
#include "ProcessLib/LocalAssemblerTraits.h"
#include "ProcessLib/Parameter.h"
#include "ProcessLib/Parameter/Parameter.h"
#include "ProcessLib/Utils/InitShapeMatrices.h"
#include "GroundwaterFlowProcessData.h"

Expand Down Expand Up @@ -81,7 +81,7 @@ class LocalAssemblerData
}

void assembleConcrete(
double const /*t*/, std::vector<double> const& local_x,
double const t, std::vector<double> const& local_x,
NumLib::LocalToGlobalIndexMap::RowColumnIndices const& indices,
GlobalMatrix& /*M*/, GlobalMatrix& K, GlobalVector& b) override
{
Expand All @@ -91,11 +91,15 @@ class LocalAssemblerData
IntegrationMethod integration_method(_integration_order);
unsigned const n_integration_points = integration_method.getNumberOfPoints();

for (std::size_t ip(0); ip < n_integration_points; ip++)
SpatialPosition pos;
pos.setElementID(_element.getID());

for (unsigned ip = 0; ip < n_integration_points; ip++)
{
pos.setIntegrationPoint(ip);
auto const& sm = _shape_matrices[ip];
auto const& wp = integration_method.getWeightedPoint(ip);
auto const k = _process_data.hydraulic_conductivity(_element);
auto const k = _process_data.hydraulic_conductivity.getTuple(t, pos).front();

_localA.noalias() += sm.dNdx.transpose() * k * sm.dNdx *
sm.detJ * wp.getWeight();
Expand Down
8 changes: 3 additions & 5 deletions ProcessLib/GroundwaterFlow/GroundwaterFlowProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace MeshLib
namespace ProcessLib
{

template <typename ReturnType, typename... Args>
template <typename T>
struct Parameter;

namespace GroundwaterFlow
Expand All @@ -28,9 +28,7 @@ namespace GroundwaterFlow
struct GroundwaterFlowProcessData
{
GroundwaterFlowProcessData(
ProcessLib::Parameter<double, MeshLib::Element const&> const&
hydraulic_conductivity_
)
Parameter<double> const& hydraulic_conductivity_)
: hydraulic_conductivity(hydraulic_conductivity_)
{}

Expand All @@ -47,7 +45,7 @@ struct GroundwaterFlowProcessData
//! Assignments are not needed.
void operator=(GroundwaterFlowProcessData&&) = delete;

Parameter<double, MeshLib::Element const&> const& hydraulic_conductivity;
Parameter<double> const& hydraulic_conductivity;
};

} // namespace GroundwaterFlow
Expand Down
103 changes: 0 additions & 103 deletions ProcessLib/InitialCondition.cpp

This file was deleted.

99 changes: 0 additions & 99 deletions ProcessLib/InitialCondition.h

This file was deleted.

Loading
0