Commit 12240d1b authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#873 Parameters: introduce a parameter for time dependency, which at the...

#873 Parameters: introduce a parameter for time dependency, which at the moment default to an empty struct named None.
parent da5b04b1
......@@ -350,6 +350,9 @@
BE4478871AA740F800665010 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE4478861AA740F800665010 /* main.cpp */; };
BE4478891AA7415000665010 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE4478881AA7415000665010 /* main.cpp */; };
BE44C05B1AA463DF0030FA26 /* Pragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE44C0581AA463DF0030FA26 /* Pragma.hpp */; };
BE44E3AF1CAA7748006DDE6F /* None.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE44E3AC1CAA7748006DDE6F /* None.hpp */; };
BE44E3B51CAA7775006DDE6F /* TimeDependency.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE44E3B21CAA7775006DDE6F /* TimeDependency.hpp */; };
BE44E3B61CAA7775006DDE6F /* TimeDependency.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE44E3B31CAA7775006DDE6F /* TimeDependency.hxx */; };
BE44ECC31AC9463D00561634 /* GodOfDofManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE44ECC01AC9463D00561634 /* GodOfDofManager.cpp */; };
BE44ECC41AC9463D00561634 /* GodOfDofManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE44ECC11AC9463D00561634 /* GodOfDofManager.hpp */; };
BE44ECC51AC9463D00561634 /* GodOfDofManager.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE44ECC21AC9463D00561634 /* GodOfDofManager.hxx */; };
......@@ -4315,6 +4318,9 @@
BE4478861AA740F800665010 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
BE4478881AA7415000665010 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
BE44C0581AA463DF0030FA26 /* Pragma.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Pragma.hpp; sourceTree = "<group>"; };
BE44E3AC1CAA7748006DDE6F /* None.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = None.hpp; path = TimeDependency/None.hpp; sourceTree = "<group>"; };
BE44E3B21CAA7775006DDE6F /* TimeDependency.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = TimeDependency.hpp; path = TimeDependency/TimeDependency.hpp; sourceTree = "<group>"; };
BE44E3B31CAA7775006DDE6F /* TimeDependency.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = TimeDependency.hxx; path = TimeDependency/TimeDependency.hxx; sourceTree = "<group>"; };
BE44ECC01AC9463D00561634 /* GodOfDofManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GodOfDofManager.cpp; sourceTree = "<group>"; };
BE44ECC11AC9463D00561634 /* GodOfDofManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GodOfDofManager.hpp; sourceTree = "<group>"; };
BE44ECC21AC9463D00561634 /* GodOfDofManager.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GodOfDofManager.hxx; sourceTree = "<group>"; };
......@@ -6781,6 +6787,16 @@
path = Pragma;
sourceTree = "<group>";
};
BE44E3AA1CAA7727006DDE6F /* TimeDependency */ = {
isa = PBXGroup;
children = (
BE44E3AC1CAA7748006DDE6F /* None.hpp */,
BE44E3B21CAA7775006DDE6F /* TimeDependency.hpp */,
BE44E3B31CAA7775006DDE6F /* TimeDependency.hxx */,
);
name = TimeDependency;
sourceTree = "<group>";
};
BE4529231A4189F3006A1577 /* PostProcessing */ = {
isa = PBXGroup;
children = (
......@@ -7779,6 +7795,7 @@
BE6B1AF31B0A343D00CC2135 /* Parameter.hxx */,
BE9EA61A1C89F50900836E0E /* ParameterAtDof.hpp */,
135A9AC81C9C5EE200C66720 /* ParameterAtQuadraturePoint.hpp */,
BE44E3AA1CAA7727006DDE6F /* TimeDependency */,
BEED7BB51C7C9647002C4C15 /* Compound */,
BE6B1AF61B0A343D00CC2135 /* Policy */,
BE6199471B0F61C400906290 /* Instances */,
......@@ -10072,6 +10089,7 @@
BEED7BBB1C7C9670002C4C15 /* Solid.hpp in Headers */,
BE625B311BCBB0D200FB316D /* FiberList.hxx in Headers */,
BE3C40991B0F7DD900396F68 /* ComputeGradientBasedElasticityTensor.hpp in Headers */,
BE44E3B51CAA7775006DDE6F /* TimeDependency.hpp in Headers */,
BE625B351BCBB0D200FB316D /* ReadFiberFile.hxx in Headers */,
BEB39B881BCBE15E004C0B9D /* ParameterType.hpp in Headers */,
BEF567D71B1741B000AAA2AA /* InitParameter.hpp in Headers */,
......@@ -10080,6 +10098,8 @@
BE625B331BCBB0D200FB316D /* FillGlobalVector.hxx in Headers */,
BE646CDA1B32FD77008BD37C /* AtQuadraturePoint.hxx in Headers */,
BE6322FD1B188BF500F787CC /* LameLambda.hpp in Headers */,
BE44E3AF1CAA7748006DDE6F /* None.hpp in Headers */,
BE44E3B61CAA7775006DDE6F /* TimeDependency.hxx in Headers */,
BEB39B821BCBDADF004C0B9D /* FiberListManager.hpp in Headers */,
BEADAD2B1B2ED2C3001D9111 /* AtQuadraturePoint.hxx in Headers */,
BE17F3381B149A2A00EAAACE /* Configuration.hpp in Headers */,
......@@ -26,7 +26,7 @@
# include "FiniteElement/QuadratureRules/QuadraturePoint.hpp"
# include "Parameters/TimeDependency/None.hpp"
namespace HappyHeart
......@@ -73,7 +73,11 @@ namespace HappyHeart
* Actual instantiations of the class are specializations of ParameterInstance template class; a developer should
* anyway use only InitParameter() free function to instantiate a parameter.
*/
template<ParameterNS::Type TypeT>
template
<
ParameterNS::Type TypeT,
class TimeDependancyT = ParameterNS::TimeDependencyNS::None
>
class Parameter
{
......
......@@ -16,11 +16,15 @@ namespace HappyHeart
{
template<ParameterNS::Type TypeT>
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
template<class T>
Parameter<TypeT>::Parameter(T&& name,
const GeometricMeshRegion& geometric_mesh_region,
std::function<double(double)>&& time_dependant_factor)
Parameter<TypeT, TimeDependencyT>::Parameter(T&& name,
const GeometricMeshRegion& geometric_mesh_region,
std::function<double(double)>&& time_dependant_factor)
: name_(name),
geometric_mesh_region_(geometric_mesh_region),
time_dependancy_functor_(std::move(time_dependant_factor)),
......@@ -28,15 +32,23 @@ namespace HappyHeart
{ }
template<ParameterNS::Type TypeT>
void Parameter<TypeT>::TimeUpdate(double time)
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
void Parameter<TypeT, TimeDependencyT>::TimeUpdate(double time)
{
time_dependancy_factor_ = time_dependancy_functor_(time);
}
template<ParameterNS::Type TypeT>
inline typename Parameter<TypeT>::return_type Parameter<TypeT>::GetConstantValue() const
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline typename Parameter<TypeT, TimeDependencyT>::return_type Parameter<TypeT, TimeDependencyT>::GetConstantValue() const
{
assert(IsConstant() && "This method is relevant only for spatially constant parameters.");
......@@ -44,8 +56,12 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline typename Parameter<TypeT>::return_type Parameter<TypeT>
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline typename Parameter<TypeT, TimeDependencyT>::return_type Parameter<TypeT, TimeDependencyT>
::GetValue(const QuadraturePoint& quad_pt, const GeometricElt& geom_elt) const
{
if (IsConstant())
......@@ -55,8 +71,12 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline void Parameter<TypeT>::Write(const std::string& filename) const
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline void Parameter<TypeT, TimeDependencyT>::Write(const std::string& filename) const
{
std::ofstream out;
FilesystemNS::File::Create(out, filename, __FILE__, __LINE__);
......@@ -64,30 +84,46 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline void Parameter<TypeT>::Write(std::ostream& out) const
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline void Parameter<TypeT, TimeDependencyT>::Write(std::ostream& out) const
{
out << "# Name = " << GetName() << std::endl;
this->SupplWrite(out);
}
template<ParameterNS::Type TypeT>
inline const std::string& Parameter<TypeT>::GetName() const
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline const std::string& Parameter<TypeT, TimeDependencyT>::GetName() const
{
return name_;
}
template<ParameterNS::Type TypeT>
inline const GeometricMeshRegion& Parameter<TypeT>::GetGeometricMeshRegion() const noexcept
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline const GeometricMeshRegion& Parameter<TypeT, TimeDependencyT>::GetGeometricMeshRegion() const noexcept
{
return geometric_mesh_region_;
}
template<ParameterNS::Type TypeT>
inline double Parameter<TypeT>::GetTimeDependancyFactor() const noexcept
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
>
inline double Parameter<TypeT, TimeDependencyT>::GetTimeDependancyFactor() const noexcept
{
return time_dependancy_factor_;
}
......
//! \file
//
//
// None.hpp
// HappyHeart
//
// Created by Sebastien Gilles on 29/03/16.
// Copyright © 2016 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_NONE_HPP_
# define HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_NONE_HPP_
namespace HappyHeart
{
namespace ParameterNS
{
namespace TimeDependencyNS
{
struct None
{ };
} // namespace TimeDependencyNS
} // namespace ParameterNS
} // namespace HappyHeart
#endif // HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_NONE_HPP_
//! \file
//
//
// TimeDependency.hpp
// HappyHeart
//
// Created by Sebastien Gilles on 29/03/16.
// Copyright © 2016 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HPP_
# define HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HPP_
# include <memory>
# include <vector>
namespace HappyHeart
{
namespace ParameterNS
{
template<class FunctorT>
class TimeDependency
{
public:
//! Alias to self.
using self = TimeDependency<FunctorT>;
//! Alias to unique pointer.
using unique_ptr = std::unique_ptr<self>;
public:
/// \name Special members.
///@{
//! Constructor.
explicit TimeDependency(FunctorT&& functor);
//! Destructor.
~TimeDependency() = default;
//! Copy constructor.
TimeDependency(const TimeDependency&) = delete;
//! Move constructor.
TimeDependency(TimeDependency&&) = delete;
//! Copy affectation.
TimeDependency& operator=(const TimeDependency&) = delete;
//! Move affectation.
TimeDependency& operator=(TimeDependency&&) = delete;
///@}
private:
/*!
* \brief Functor which returns the time dependant factor.
*
* It takes a double (the time step) and returns the value of the time-dependant factor; a possible
* prototype is:
* \code
* [](double time) -> double
* \endcode
*
*/
const FunctorT functor_;
};
} // namespace ParameterNS
} // namespace HappyHeart
# include "Parameters/TimeDependency/TimeDependency.hxx"
#endif // HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HPP_
//! \file
//
//
// TimeDependency.hxx
// HappyHeart
//
// Created by Sebastien Gilles on 29/03/16.
// Copyright © 2016 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HXX_
# define HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HXX_
namespace HappyHeart
{
namespace ParameterNS
{
template<class FunctorT>
TimeDependency<FunctorT>::TimeDependency(FunctorT&& functor)
: functor_(std::move(functor))
{ }
} // namespace ParameterNS
} // namespace HappyHeart
#endif // HAPPY_HEART_x_PARAMETERS_x_TIME_DEPENDENCY_x_TIME_DEPENDENCY_HXX_
Supports Markdown
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