15 #if !defined(KRATOS_PIECEWIZE_LINEAR_TABLE_H_INCLUDED )
16 #define KRATOS_PIECEWIZE_LINEAR_TABLE_H_INCLUDED
61 template<
class TArgumentType,
class TResultType = TArgumentType, std::
size_t TResultsColumns = 1>
73 typedef std::pair<TArgumentType, result_array_type>
RecordType;
85 Table() : mData(), mpXVariable(NULL) , mpYVariable(NULL)
103 mData = rOther.mData;
140 std::size_t size = mData.size();
146 return mData.begin()->second;
149 if(
X <= mData[0].first)
150 return Interpolate(
X, mData[0].first, mData[0].second, mData[1].first, mData[1].second, result);
152 for(std::size_t
i = 1 ;
i < size ;
i++)
153 if(
X <= mData[
i].first)
154 return Interpolate(
X, mData[
i-1].first, mData[
i-1].second, mData[
i].first, mData[
i].second, result);
157 return Interpolate(
X, mData[size-2].first, mData[size-2].second, mData[size-1].first, mData[size-1].second, result);
163 std::size_t size = mData.size();
169 return mData.begin()->second;
171 if(
X <= mData[0].first)
172 return mData[0].second;
174 for(std::size_t
i = 1 ;
i < size ;
i++)
175 if(
X <= mData[
i].first)
176 return ((
X - mData[
i-1].first) < (mData[
i].first -
X)) ? mData[
i-1].second : mData[
i].second;
179 return mData[size-1].second;
185 std::size_t size = mData.size();
191 return mData.begin()->second;
193 if(
X <= mData[0].first)
194 return mData[0].second;
196 for(std::size_t
i = 1 ;
i < size ;
i++)
197 if(
X <= mData[
i].first)
198 return ((
X - mData[
i-1].first) < (mData[
i].first -
X)) ? mData[
i-1].second : mData[
i].second;
201 return mData[size-1].second;
204 TResultType&
Interpolate(TArgumentType
const& X, TArgumentType
const&
X1, TResultType
const& Y1, TArgumentType
const&
X2, TResultType
const& Y2, TResultType& Result)
206 double epsilon = 1
e-12;
209 TResultType dy = Y2 - Y1;
214 scale = (
X -
X1) / dx_norm;
216 Result = Y1 + dy * scale;
222 void PushBack(TArgumentType
const& X, TResultType
const& Y)
264 virtual std::string
Info()
const
382 template<
class TArgumentType,
class TResultType>
387 template<
class TArgumentType,
class TResultType>
392 rOStream << std::endl;
This class represents the value of its variable depending to other variable.
Definition: piecewize_linear_table.h:63
YVariableType & GetYVariable()
Definition: piecewize_linear_table.h:248
std::vector< RecordType > TableContainerType
Definition: piecewize_linear_table.h:75
std::array< TResultType, TResultsColumns > result_array_type
Definition: piecewize_linear_table.h:71
TResultType GetValue(TArgumentType const &X) const
Definition: piecewize_linear_table.h:138
TResultType const & GetNearestValue(TArgumentType const &X) const
Definition: piecewize_linear_table.h:183
result_array_type & GetNearestRow(TArgumentType const &X)
Definition: piecewize_linear_table.h:161
TResultType & Interpolate(TArgumentType const &X, TArgumentType const &X1, TResultType const &Y1, TArgumentType const &X2, TResultType const &Y2, TResultType &Result)
Definition: piecewize_linear_table.h:204
Variable< TArgumentType > XVariableType
Definition: piecewize_linear_table.h:77
virtual std::string Info() const
Turn back information as a string.
Definition: piecewize_linear_table.h:264
TResultType & operator[](TArgumentType &X)
Definition: piecewize_linear_table.h:128
std::pair< TArgumentType, result_array_type > RecordType
Definition: piecewize_linear_table.h:73
Variable< TResultType > YVariableType
Definition: piecewize_linear_table.h:78
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: piecewize_linear_table.h:276
KRATOS_CLASS_POINTER_DEFINITION(Table)
Pointer definition of Table.
TResultType const & operator[](TArgumentType const &X) const
Definition: piecewize_linear_table.h:122
XVariableType & GetXVariable()
Definition: piecewize_linear_table.h:243
void PushBack(TArgumentType const &X, TResultType const &Y)
Definition: piecewize_linear_table.h:222
virtual ~Table()
Destructor.
Definition: piecewize_linear_table.h:95
TResultType operator()(TArgumentType const &X) const
Definition: piecewize_linear_table.h:116
Table & operator=(Table const &rOther)
Assignment operator.
Definition: piecewize_linear_table.h:101
Table(XVariableType const &XVariable, YVariableType const &YVariable)
Default constructor.
Definition: piecewize_linear_table.h:90
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: piecewize_linear_table.h:270
TableContainerType const & Data() const
Definition: piecewize_linear_table.h:238
Table()
Default constructor.
Definition: piecewize_linear_table.h:85
TableContainerType & Data()
Definition: piecewize_linear_table.h:233
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
X2
Definition: generate_frictional_mortar_condition.py:120
X1
Definition: generate_frictional_mortar_condition.py:119
a
Definition: generate_stokes_twofluid_element.py:77
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31