https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 0fde67c0ca8818233131619e1c07b8c4be4094a0 authored by Christoph Lehmann on 01 May 2016, 20:11:48 UTC
[TES] chaged reaction taming strategy
Tip revision: 0fde67c
InitialCondition.cpp
/**
 * \copyright
 * Copyright (c) 2012-2016, 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 <boost/optional.hpp>
#include <logog/include/logog.hpp>

#include "MathLib/Point3d.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Mesh.h"

#include "BaseLib/ConfigTree.h"

namespace ProcessLib
{
std::unique_ptr<InitialCondition> createUniformInitialCondition(
    BaseLib::ConfigTree const& config, int const /*n_components*/)
{
	config.checkConfParam("type", "Uniform");

	auto value = config.getConfParam<double>("value");
	DBUG("Using value %g", value);

	return std::unique_ptr<InitialCondition>(
	    new UniformInitialCondition(value));
}

std::unique_ptr<InitialCondition> createMeshPropertyInitialCondition(
    BaseLib::ConfigTree const& config,
    MeshLib::Mesh const& mesh,
    int const n_components)
{
	auto field_name = config.getConfParam<std::string>("field_name");
	DBUG("Using field_name %s", field_name.c_str());

	if (!mesh.getProperties().hasPropertyVector(field_name))
	{
		ERR("The required property %s does not exists in the mesh.",
		    field_name.c_str());
		std::abort();
	}
	auto const& property =
	    mesh.getProperties().template getPropertyVector<double>(field_name);
	if (!property)
	{
		ERR("The required property %s is not of the requested type.",
		    field_name.c_str());
		std::abort();
	}

	if (property->getNumberOfComponents() !=
	    static_cast<std::size_t>(n_components))
	{
		ERR("The required property %s has different number of components %d, "
		    "expected %d.",
		    field_name.c_str(), property->getNumberOfComponents(), n_components);
		std::abort();
	}
	return std::unique_ptr<InitialCondition>(
	    new MeshPropertyInitialCondition(*property));
}

}  // namespace ProcessLib
back to top