Commit a00e96fe authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#873 Test/Parameter time dependency: add source operator. Its value is not yet...

#873 Test/Parameter time dependency: add source operator. Its value is not yet sought (it wouldn't work yet).
parent fdcf73b7
......@@ -552,3 +552,61 @@ Solid = {
} -- Solid
TransientSource1 = {
-- How is given the transient source value (as a constant, as a Lua function, per quadrature point, etc...)
-- Expected format: {"VALUE1", "VALUE2", ...}
-- Constraint: ops_in(v, {'ignore', 'constant', 'lua_function'})
nature = {"constant", "constant", "constant"},
-- Value of the transient source in the case nature is 'constant'(and also initial value if nature is
-- 'at_quadrature_point'; irrelevant otherwise).
-- Expected format: {VALUE1, VALUE2, ...}
scalar_value = { 10. , 20., 30.},
-- Value of the transient source in the case nature is 'lua_function'(and also initial value if nature is
-- 'at_quadrature_point'; irrelevant otherwise).
-- Function expects as arguments global coordinates (coordinates in the mesh).
-- Expected format: Function in Lua language, for instance:
-- -- function(arg1, arg2, arg3)
-- return arg1 + arg2 -
-- arg3
-- end
-- sin, cos and tan require a 'math.'
-- preffix.
-- If you do not wish to provide one, put anything you want (e.g. 'none'): the
-- content is not interpreted by Ops until an actual use of the underlying function.
lua_function_x = none,
-- Value of the transient source in the case nature is 'lua_function'(and also initial value if nature is
-- 'at_quadrature_point'; irrelevant otherwise).
-- Function expects as arguments global coordinates (coordinates in the mesh).
-- Expected format: Function in Lua language, for instance:
-- -- function(arg1, arg2, arg3)
-- return arg1 + arg2 -
-- arg3
-- end
-- sin, cos and tan require a 'math.'
-- preffix.
-- If you do not wish to provide one, put anything you want (e.g. 'none'): the
-- content is not interpreted by Ops until an actual use of the underlying function.
lua_function_y = none,
-- Value of the transient source in the case nature is 'lua_function'(and also initial value if nature is
-- 'at_quadrature_point'; irrelevant otherwise).
-- Function expects as arguments global coordinates (coordinates in the mesh).
-- Expected format: Function in Lua language, for instance:
-- -- function(arg1, arg2, arg3)
-- return arg1 + arg2 -
-- arg3
-- end
-- sin, cos and tan require a 'math.'
-- preffix.
-- If you do not wish to provide one, put anything you want (e.g. 'none'): the
-- content is not interpreted by Ops until an actual use of the underlying function.
lua_function_z = none
} -- TransientSource1
......@@ -164,7 +164,6 @@ namespace HappyHeart
::Perform(return_type value_without_time_factor,
const TimeDependencyT& time_dependency_object)
{
std::cout << "Time factor should be applied here." << std::endl;
return time_dependency_object.ApplyTimeFactor(value_without_time_factor);
}
......@@ -176,7 +175,6 @@ namespace HappyHeart
const ParameterNS::TimeDependencyNS::None<TypeT>& unused)
{
static_cast<void>(unused);
std::cout << "No time factor to apply." << std::endl;
return value_without_time_factor;
}
......
......@@ -41,9 +41,13 @@ namespace HappyHeart
//! This object is never to be instantiated, so nullptr_t is a relevant choice.
//!
using unique_ptr = std::unique_ptr<None>;
//! Defined for conveniency; do nothing.
void Update() { }
};
......
......@@ -17,6 +17,7 @@
# include "Core/InputParameter/FElt/Unknown.hpp"
# include "Core/InputParameter/FElt/NumberingSubset.hpp"
# include "Core/InputParameter/Parameter/Solid/Solid.hpp"
# include "Core/InputParameter/Parameter/Source/TransientSource.hpp"
namespace HappyHeart
......@@ -65,6 +66,12 @@ namespace HappyHeart
};
enum class SourceIndex
{
source = 1,
};
using InputParameterTuple = std::tuple
<
......@@ -86,7 +93,9 @@ namespace HappyHeart
InputParameter::Solid,
InputParameter::Result
InputParameter::Result,
InputParameter::TransientSource<EnumUnderlyingType(SourceIndex::source)>
>;
......
......@@ -37,7 +37,8 @@ namespace HappyHeart
void Model::SupplInitialize(const InputParameterList& input_parameter_data)
{
decltype(auto) mesh = GetGeometricMeshRegion(EnumUnderlyingType(MeshIndex::mesh));
decltype(auto) god_of_dof = GetGodOfDof(EnumUnderlyingType(MeshIndex::mesh));
decltype(auto) mesh = god_of_dof.GetGeometricMeshRegion();
auto linear = [](double time)
{
......@@ -67,10 +68,36 @@ namespace HappyHeart
>("Poisson ratio",
mesh,
input_parameter_data);
using parameter_type = InputParameter::TransientSource<EnumUnderlyingType(SourceIndex::source)>;
source_parameter_ =
InitThreeDimensionalParameter
<
parameter_type,
ParameterNS::TimeDependency
>("Source",
mesh,
input_parameter_data);
assert(!(!source_parameter_));
using operator_type = decltype(source_operator_)::element_type;
decltype(auto) felt_space = god_of_dof.GetFEltSpace(EnumUnderlyingType(FEltSpaceIndex::index));
decltype(auto) unknown = UnknownManager::GetInstance().GetUnknown(EnumUnderlyingType(UnknownIndex::scalar));
source_operator_ =
std::make_unique<operator_type>(felt_space,
unknown,
mesh.GetDimension(),
DetermineDefaultQuadratureRule(5),
DoComputeProcessorWiseLocal2Global::no,
*source_parameter_);
}
void Model::Forward()
{
......
......@@ -15,6 +15,7 @@
# include "Parameters/TimeDependency/TimeDependency.hpp"
# include "Operators/ConformInterpolatorInstances/SubsetOrSuperset.hpp"
# include "Operators/GlobalVariationalOperatorInstances/LinearForm/TransientSource.hpp"
# include "Model/Model.hpp"
......@@ -157,6 +158,10 @@ namespace HappyHeart
//! Non constant accessor to scalar parameter that does not vary with time.
scalar_immutable_type& GetNonCstPoissonRatio() noexcept;
//! Constant accessor to the source operator.
const GlobalVariationalOperatorNS::TransientSource<ParameterNS::TimeDependency>&
GetSourceOperator() const noexcept;
private:
......@@ -171,6 +176,15 @@ namespace HappyHeart
//! Poisson ratio (i.e. scalar parameter) that in the test may not vary with time.
typename scalar_immutable_type::unique_ptr poisson_ratio_ = nullptr;
//! Source operator.
typename GlobalVariationalOperatorNS::TransientSource<ParameterNS::TimeDependency>::const_unique_ptr
source_operator_ = nullptr;
//! Underlying Parameter used to define source operator.
typename Parameter<ParameterNS::Type::vector, ParameterNS::TimeDependency>::unique_ptr
source_parameter_ = nullptr;
};
......
......@@ -62,6 +62,14 @@ namespace HappyHeart
{
return const_cast<scalar_varying_type&>(GetYoungModulus());
}
inline const GlobalVariationalOperatorNS::TransientSource<ParameterNS::TimeDependency>&
Model::GetSourceOperator() const noexcept
{
assert(!(!source_operator_));
return *source_operator_;
}
} // namespace TestParameterTimeDependencyNS
......
......@@ -36,7 +36,7 @@ int main(int argc, char ** argv)
TestParameterTimeDependencyNS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
input_parameter_data.PrintUnused(std::cout);
//input_parameter_data.PrintUnused(std::cout);
}
catch(const std::exception& e)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment