/*!\file SpcStatic.c * \brief: implementation of the SpcStatic object */ #ifdef HAVE_CONFIG_H #include #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif #include #include #include "../../include/include.h" #include "../../shared/shared.h" #include "../../EnumDefinitions/EnumDefinitions.h" #include "../../Container/Container.h" #include "../objects.h" /*SpcStatic constructors and destructor*/ /*FUNCTION SpcStatic::SpcStatic(){{{1*/ SpcStatic::SpcStatic(){ return; } /*}}}1*/ /*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{1*/ SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,double spc_value,int spc_analysis_type){ sid=spc_sid; nodeid=spc_nodeid; dof=spc_dof; value=spc_value; analysis_type=spc_analysis_type; return; } /*}}}1*/ /*FUNCTION SpcStatic::~SpcStatic{{{1*/ SpcStatic::~SpcStatic(){ return; } /*}}}1*/ /*Object virtual functions definitions:*/ /*FUNCTION SpcStatic::Echo {{{1*/ void SpcStatic::Echo(void){ printf("SpcStatic:\n"); printf(" sid: %i\n",sid); printf(" nodeid: %i\n",nodeid); printf(" dof: %i\n",dof); printf(" value: %g\n",value); printf(" analysis_type: %s\n",EnumToStringx(analysis_type)); return; } /*}}}1*/ /*FUNCTION SpcStatic::DeepEcho {{{1*/ void SpcStatic::DeepEcho(void){ printf("SpcStatic:\n"); printf(" sid: %i\n",sid); printf(" nodeid: %i\n",nodeid); printf(" dof: %i\n",dof); printf(" value: %g\n",value); printf(" analysis_type: %s\n",EnumToStringx(analysis_type)); return; } /*}}}1*/ /*FUNCTION SpcStatic::Id {{{1*/ int SpcStatic::Id(void){ return sid; } /*}}}1*/ /*FUNCTION SpcStatic::MyRank {{{1*/ int SpcStatic::MyRank(void){ extern int my_rank; return my_rank; } /*}}}1*/ #ifdef _SERIAL_ /*FUNCTION SpcStatic::Marshall {{{1*/ void SpcStatic::Marshall(char** pmarshalled_dataset){ char* marshalled_dataset=NULL; int enum_type=0; /*recover marshalled_dataset: */ marshalled_dataset=*pmarshalled_dataset; /*get enum type of SpcStatic: */ enum_type=SpcStaticEnum; /*marshall enum: */ memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); /*marshall SpcStatic data: */ memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid); memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid); memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof); memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value); memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type); *pmarshalled_dataset=marshalled_dataset; return; } /*}}}1*/ /*FUNCTION SpcStatic::MarshallSize {{{1*/ int SpcStatic::MarshallSize(){ return sizeof(sid) +sizeof(nodeid) +sizeof(dof) +sizeof(value) +sizeof(analysis_type) +sizeof(int); //sizeof(int) for enum type } /*}}}1*/ /*FUNCTION SpcStatic::Demarshall {{{1*/ void SpcStatic::Demarshall(char** pmarshalled_dataset){ char* marshalled_dataset=NULL; /*recover marshalled_dataset: */ marshalled_dataset=*pmarshalled_dataset; /*this time, no need to get enum type, the pointer directly points to the beginning of the *object data (thanks to DataSet::Demarshall):*/ memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid); memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid); memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof); memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value); memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type); /*return: */ *pmarshalled_dataset=marshalled_dataset; return; } /*}}}1*/ #endif /*FUNCTION SpcStatic::ObjectEnum{{{1*/ int SpcStatic::ObjectEnum(void){ return SpcStaticEnum; } /*}}}1*/ /*FUNCTION SpcStatic::copy {{{1*/ Object* SpcStatic::copy() { return new SpcStatic(*this); } /*}}}1*/ /*Constraint virtual functions definitions: */ /*FUNCTION SpcStatic::InAnalysis{{{1*/ bool SpcStatic::InAnalysis(int in_analysis_type){ if (in_analysis_type==this->analysis_type) return true; else return false; } /*}}}*/ /*FUNCTION SpcStatic::ConstrainNode{{{1*/ void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){ Node* node=NULL; /*Chase through nodes and find the node to which this SpcStatic applys: */ node=(Node*)nodes->GetObjectById(NULL,nodeid); /*Apply constraint: */ if(node){ //in case the spc is dealing with a node on another cpu node->ApplyConstraint(dof,value); } } /*}}}*/ /*SpcStatic functions*/ /*FUNCTION SpcStatic::GetDof {{{1*/ int SpcStatic::GetDof(){ return dof; } /*}}}1*/ /*FUNCTION SpcStatic::GetNodeId {{{1*/ int SpcStatic::GetNodeId(){ return nodeid; } /*}}}1*/ /*FUNCTION SpcStatic::GetValue {{{1*/ double SpcStatic::GetValue(){ _assert_(!isnan(value)); return value; } /*}}}1*/