Page MenuHomec4science

ref_node_akantu.hh
No OneTemporary

File Metadata

Created
Tue, Jul 9, 21:16

ref_node_akantu.hh

/**
* @file ref_node_akantu.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
*
* @date Tue Jul 22 14:47:56 2014
*
* @brief This is the generic reference over Akantu nodes
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale 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.
*
* LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_REF_NODE_AKANTU_HH__
#define __LIBMULTISCALE_REF_NODE_AKANTU_HH__
/* -------------------------------------------------------------------------- */
#include "ref_node_continuum.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template <UInt Dim> class AkantuDOFWrapper;
/* -------------------------------------------------------------------------- */
template <UInt Dim> class IteratorNodesAkantu;
template <UInt Dim> class DomainAkantu;
template <UInt Dim> class ContainerNodesAkantu;
template <UInt Dim> class RefElemAkantu;
class ComparatorRefNodeAkantu;
/* -------------------------------------------------------------------------- */
/**
* Class RefNodeAkantu
*/
template <UInt _Dim>
class RefNodeAkantu :public RefNode<_Dim>
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
RefNodeAkantu();
RefNodeAkantu(UInt ind);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
bool operator == (RefNodeAkantu<_Dim> & ref);
//! return residual value for dimention coord
Real & force(UInt coord);
//! return residual value for dimention coord
Real & appliedForce(UInt coord);
//! return acceleration value for dimention coord
Real & acceleration(UInt coord);
//! return initial position value for dimention coord
Real & position0(UInt coord);
//! return initial position value for dimention coord
AccessorNodalDof<_Dim,_position> position(UInt coord);
//! return displacement value for dimention coord
Real & displacement(UInt coord);
//! return velocity value for dimention coord
Real & velocity(UInt coord);
//! return mass value
Real & mass();
#ifdef AKANTU_HEAT_TRANSFER
//! return temperature
Real & temperature();
//! return temperature variation value
Real & temperatureVar();
//! return the external (applied) heat rate
Real & externalHeatRate();
//! return the heat rate (residual)
Real & heatRate();
//! return heat capacity
Real & capacity();
#endif
//! read or set boundary value
bool & boundary(UInt coord);
//! return id of the degree of freedom
UInt id();
//! set displacement value for dimention coord
void setDisplacement(UInt coord,Real value);
//! set velocity value for dimention coord
void setVelocity(UInt coord,Real value);
//! set forces value for dimention coord
void setForce(UInt coord,Real value);
//! set forces value for dimention coord
void setResidual(UInt coord,Real value);
//! set acceleration value for dimention coord
void setAcceleration(UInt coord,Real value);
//! return the pointed node index
UInt getIndex(){return index;};
//! set pointers to akantu objects
void setAkantuPointers(AkantuDOFWrapper<_Dim> & dof);
//! set heat transfer flag
void setHeatTransferFlag(bool flag);
//! get heat transfer flag
bool getHeatTransferFlag();
//! return the dof_type
DOFType getDOFType();
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
//! generic container of the original model container
typedef DomainAkantu<_Dim> Domain;
//! node comparator class to be usable in maps
typedef ComparatorRefNodeAkantu RefComparator;
//! iterators need to access model field
friend class IteratorNodesAkantu<_Dim>;
//! containers need to access index field
friend class ContainerNodesAkantu<_Dim>;
//! elem reference need access
friend class RefElemAkantu<_Dim>;
static const UInt Dim = _Dim;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
//! pointer to displacement field
Real * field_disp;
//! pointer to velocity field
Real * field_vel;
//! pointer to residual field
Real * field_res;
//! pointer to mass field
Real * field_mass;
//! pointer to accel field
Real * field_accel;
//! pointer to applied force
Real * field_applied_force;
//! pointer to initial position field
Real * field_pos0;
//! pointer to temperature field
Real * field_temperature;
//! pointer to temperatureVar field
Real * field_temperatureVar;
//! pointer to external heat rate field
Real * field_external_heat_rate;
//! pointer to heat rate field
Real * field_heat_rate;
//! pointer to heat capacity field
Real * field_capacity;
//! pointer to boundary field
bool * field_boundary;
// flag for heat transfer
bool heat_transfer_flag;
//! internal index
UInt index;
//! akantu mesh
akantu::Mesh * mesh;
};
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline RefNodeAkantu<_Dim>::RefNodeAkantu() :
field_disp(NULL),
field_vel(NULL),
field_res(NULL),
field_mass(NULL),
field_accel(NULL),
field_applied_force(NULL),
field_pos0(NULL),
field_temperature(NULL),
field_temperatureVar(NULL),
field_external_heat_rate(NULL),
field_heat_rate(NULL),
field_capacity(NULL),
field_boundary(NULL),
heat_transfer_flag(false),
mesh(NULL){
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline bool RefNodeAkantu<_Dim>::operator ==(RefNodeAkantu<_Dim> & ref){
return (ref.index == index);
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::force(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_res,"uninitialized field");
return field_res[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::appliedForce(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_applied_force,"uninitialized field");
return field_applied_force[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::acceleration(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_accel,"uninitialized field");
return field_accel[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::position0(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_pos0,"uninitialized field");
return field_pos0[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline AccessorNodalDof<_Dim,_position> RefNodeAkantu<_Dim>::position(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_pos0,"uninitialized field");
LM_ASSERT(field_disp,"uninitialized field");
return AccessorNodalDof<_Dim,_position>(*this,coord);
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::displacement(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_disp,"uninitialized field");
return field_disp[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::velocity(UInt coord){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_vel,"uninitialized field");
return field_vel[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::mass(){
LM_ASSERT(field_mass,"uninitialized field");
return field_mass[_Dim*index];
}
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_HEAT_TRANSFER
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::temperature(){
LM_ASSERT(field_temperature,"uninitialized field");
return field_temperature[index];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::temperatureVar(){
LM_ASSERT(field_temperatureVar,"uninitialized field");
return field_temperatureVar[index];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::externalHeatRate(){
LM_ASSERT(field_external_heat_rate,"uninitialized field");
return field_external_heat_rate[index];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::heatRate(){
LM_ASSERT(field_heat_rate,"uninitialized field");
return field_heat_rate[index];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline Real & RefNodeAkantu<_Dim>::capacity(){
LM_ASSERT(field_capacity,"uninitialized field");
return field_capacity[index];
}
#endif
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline UInt RefNodeAkantu<_Dim>::id(){
LM_TOIMPLEMENT;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setDisplacement(UInt coord,Real value){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_disp,"uninitialized field");
field_disp[_Dim*index+coord] = value;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setVelocity(UInt coord,Real value){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_vel,"uninitialized field");
field_vel[_Dim*index+coord] = value;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setForce(UInt coord,Real value){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_res,"uninitialized field");
field_res[_Dim*index+coord] = value;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setResidual(UInt coord,Real value){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_res,"uninitialized field");
field_res[_Dim*index+coord] = value;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setAcceleration(UInt coord,Real value){
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_accel,"uninitialized field");
field_accel[_Dim*index+coord] = value;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline bool & RefNodeAkantu<_Dim>::boundary(UInt coord){ //
LM_ASSERT(coord < _Dim,"out of dimension coordinate");
LM_ASSERT(field_boundary,"uninitialized field");
return field_boundary[_Dim*index+coord];
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline std::ostream& operator << (std::ostream& os,RefNodeAkantu<_Dim> & ref){
UInt n = ref.getIndex();
os << "Akantu Node reference : " << n
<< " [P] ";
for (UInt i = 0; i < _Dim; ++i) os << " " << ref.position(i);
os << " [P0] ";
for (UInt i = 0; i < _Dim; ++i) os << " " << ref.position0(i);
os << " [V] ";
for (UInt i = 0; i < _Dim; ++i) os << " " << ref.velocity(i);
os << " [F] ";
for (UInt i = 0; i < _Dim; ++i) os << " " << ref.force(i);
return os;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline void RefNodeAkantu<_Dim>::setHeatTransferFlag(bool flag){
heat_transfer_flag=flag;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline bool RefNodeAkantu<_Dim>::getHeatTransferFlag(){
return heat_transfer_flag;
}
/* -------------------------------------------------------------------------- */
template <UInt _Dim>
inline DOFType RefNodeAkantu<_Dim>::getDOFType(){
if (mesh->isPureGhostNode(this->index)) return dt_ghost;
if (mesh->isLocalOrMasterNode(this->index)) return dt_local_master;
else return dt_local_slave;
}
/* -------------------------------------------------------------------------- */
class ComparatorRefNodeAkantu{
public:
template <UInt _Dim>
bool operator()(RefNodeAkantu<_Dim> & r1,RefNodeAkantu<_Dim> & r2) const{
// return r1.index_atome < r2.index_atome;
LM_TOIMPLEMENT;
}
template <UInt _Dim>
bool operator()(const RefNodeAkantu<_Dim> & r1,const RefNodeAkantu<_Dim> & r2) const{
LM_TOIMPLEMENT;
}
};
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_REF_NODE_AKANTU_HH__ */

Event Timeline