Commit a167c9d4 authored by Cristiano Malossi's avatar Cristiano Malossi
Browse files

Adding a function class for 0D solver, as for other BCHandlers.

parent 4f3fdcd5
......@@ -27,6 +27,10 @@ ADD_SUBDIRECTORY(fem)
SET(HEADERS ${HEADERS} ${fem_HEADERS})
SET(SOURCES ${SOURCES} ${fem_SOURCES})
ADD_SUBDIRECTORY(function)
SET(HEADERS ${HEADERS} ${function_HEADERS})
SET(SOURCES ${SOURCES} ${function_SOURCES})
ADD_SUBDIRECTORY(solver)
SET(HEADERS ${HEADERS} ${solver_HEADERS})
SET(SOURCES ${SOURCES} ${solver_SOURCES})
......
......@@ -37,7 +37,7 @@
#ifndef ZeroDimensionalBC_H
#define ZeroDimensionalBC_H 1
#include <lifev/zero_dimensional/solver/ZeroDimensionalDefinitions.hpp>
#include <lifev/zero_dimensional/function/ZeroDimensionalFunction.hpp>
namespace LifeV
{
......@@ -55,8 +55,8 @@ public:
//! @name Type definitions
//@{
typedef boost::function<Real ( const Real& ) > function_Type;
typedef ZeroDimensionalBCType bcType_Type;
typedef ZeroDimensionalFunction bcFunction_Type;
typedef ZeroDimensionalBCType bcType_Type;
//@}
......@@ -65,11 +65,11 @@ public:
//@{
//! Constructor
explicit ZeroDimensionalBC() : M_function(), M_bcType() {}
explicit ZeroDimensionalBC() : M_bcType(), M_bcFunction() {}
ZeroDimensionalBC ( const ZeroDimensionalBC& bc ) :
M_function ( bc.M_function ),
M_bcType ( bc.M_bcType ) {}
M_bcType ( bc.M_bcType ),
M_bcFunction ( bc.M_bcFunction ) {}
//! Destructor
virtual ~ZeroDimensionalBC() {}
......@@ -87,7 +87,7 @@ public:
*/
Real evaluate ( const Real& time ) const
{
return M_function ( time );
return M_bcFunction ( time );
}
//@}
......@@ -100,19 +100,19 @@ public:
/*!
@param function the user defined function
*/
void setBC ( const bcType_Type& bcType, const function_Type& function )
void setBC ( const bcType_Type& bcType, const bcFunction_Type& bcFunction )
{
M_bcType = bcType;
M_function = function;
M_bcFunction = bcFunction;
}
//! Set the function
/*!
@param function the user defined function
*/
void setFunction ( const function_Type& function )
void setBCFunction ( const bcFunction_Type& function )
{
M_function = function;
M_bcFunction = function;
}
//! Set the type
......@@ -130,30 +130,30 @@ public:
//! @name Get Methods
//@{
//! Get the function
//! Get the type
/*!
@return the user defined function
@return the bc type
*/
const function_Type& function() const
const bcType_Type& bcType() const
{
return M_function;
return M_bcType;
}
//! Get the type
//! Get the bc function
/*!
@return the bc type
@return the user defined bc function
*/
const bcType_Type& bcType() const
const bcFunction_Type& bcFunction() const
{
return M_bcType;
return M_bcFunction;
}
//@}
private:
function_Type M_function;
bcType_Type M_bcType;
bcFunction_Type M_bcFunction;
};
} // Namespace LifeV
......
......@@ -57,7 +57,7 @@ public:
typedef ZeroDimensionalBC bc_Type;
typedef bc_Type::bcType_Type bcType_Type;
typedef bc_Type::function_Type function_Type;
typedef bc_Type::bcFunction_Type bcFunction_Type;
typedef markerID_Type bcFlag_Type;
typedef std::map< bcFlag_Type, bc_Type > bcContainer_Type;
......@@ -84,11 +84,13 @@ public:
//! Set the type
/*!
@param flag the bc flag
@param bcType the bc type
@param bcFunction the bc function
*/
void setBC ( const bcFlag_Type& flag, const bcType_Type& bcType, const function_Type& function )
void setBC ( const bcFlag_Type& flag, const bcType_Type& bcType, const bcFunction_Type& bcFunction )
{
M_bc[flag].setBC ( bcType, function );
M_bc[flag].setBC ( bcType, bcFunction );
}
//@}
......
SET(function_HEADERS
function/ZeroDimensionalFunction.hpp
CACHE INTERNAL "")
SET(function_SOURCES
CACHE INTERNAL "")
SET(LOCAL_HEADERS)
FOREACH(INC ${function_HEADERS})
STRING(REPLACE "function/" "" LOCAL_INC ${INC})
SET(LOCAL_HEADERS ${LOCAL_HEADERS} ${LOCAL_INC})
ENDFOREACH()
INSTALL(
FILES ${LOCAL_HEADERS}
DESTINATION "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/lifev/zero_dimensional/function"
COMPONENT ${PACKAGE_NAME}
)
//@HEADER
/*
*******************************************************************************
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
This file is part of LifeV.
LifeV is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LifeV is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
//@HEADER
/*!
* @file
* @brief File containing the zero dimensional bc function
*
* @date 13-03-2013
* @author Cristiano Malossi <cristiano.malossi@epfl.ch>
*
* @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
*/
#ifndef ZeroDimensionalFunction_H
#define ZeroDimensionalFunction_H
#include <lifev/zero_dimensional/solver/ZeroDimensionalDefinitions.hpp>
namespace LifeV
{
//! ZeroDimensionalFunction - A boundary conditions function for zero-dimensional models.
/*!
* @author Cristiano Malossi
*
* This simple class handles the boundary condition functions for zero-dimensional models.
*/
class ZeroDimensionalFunction
{
public:
//! @name Type definitions and Enumerators
//@{
/*! @typedef function_Type */
//! Type definition for the 0D boundary function
typedef boost::function<Real ( const Real& ) > function_Type;
//@}
//! @name Constructors & Destructor
//@{
//! Empty Constructor
explicit ZeroDimensionalFunction() : M_function() {}
//! Constructor by function
/*!
* @param function the user defined function
*/
explicit ZeroDimensionalFunction ( const function_Type& function ) : M_function ( function ) {}
//! Copy constructor
/*!
* @param bcFunction ZeroDimensionalFunction
*/
ZeroDimensionalFunction ( const ZeroDimensionalFunction& bcFunction ) : M_function ( bcFunction.M_function ) {}
//! Destructor
virtual ~ZeroDimensionalFunction() {}
//@}
//! @name Operators
//@{
//! Operator=
/*!
* @param bcFunction ZeroDimensionalFunction
* @return reference to a copy of the class
*/
ZeroDimensionalFunction& operator= ( const ZeroDimensionalFunction& bcFunction )
{
if ( this != &bcFunction )
{
M_function = bcFunction.M_function;
}
return *this;
}
//! Operator()
/*!
* Evaluate the function.
*
* @param time the current time.
* @param timeStep the time step.
* @return the value of the function.
*/
Real operator() ( const Real& time ) const
{
return M_function ( time );
}
//@}
//! @name Set Methods
//@{
//! Set the function
/*!
@param function the user defined function
*/
void setFunction ( const function_Type& function )
{
M_function = function;
}
//@}
//! @name Get Methods
//@{
//! Get the function
/*!
@return the user defined function
*/
const function_Type& function() const
{
return M_function;
}
//@}
private:
function_Type M_function;
};
}
#endif // ZeroDimensionalFunction_H
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