Changeset 9298


Ignore:
Timestamp:
08/11/11 15:16:35 (14 years ago)
Author:
Mathieu Morlighem
Message:

added UpdateDynamic

Location:
issm/trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk/src/c/Container/DataSet.cpp

    r9285 r9298  
    448448void DataSet::Echo(){
    449449
    450 
    451450        vector<Object*>::iterator object;
    452451
     
    493492        int i;
    494493
     494        _assert_(this);
    495495        if(!sorted)_error_(" trying to binary search on a non-sorted dataset!");
    496496
  • TabularUnified issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp

    r9285 r9298  
    167167                        /*Now add the regular spcs*/
    168168                        else{
    169                                 if (!isnan(iomodel->spcvx[i]) || (int)iomodel->nodeonhutter[i]){
     169                                if (!isnan(iomodel->spcvx[i])){
    170170                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,iomodel->spcvx[i]/iomodel->yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
    171171                                        count++;
    172172                                }
     173                                else if (iomodel->nodeonhutter[i]){
     174                                        constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,DiagnosticHorizAnalysisEnum));
     175                                        count++;
     176                                }
    173177                               
    174                                 if (!isnan(iomodel->spcvy[i]) || (int)iomodel->nodeonhutter[i]){
    175                                         constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,iomodel->spcvy[i]/iomodel->yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
    176                                         count++;
    177                                 }
     178                                if (!isnan(iomodel->spcvy[i])){
     179                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,iomodel->spcvy[i]/iomodel->yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy.
     180                                        count++;
     181                                }
     182                                else if (iomodel->nodeonhutter[i]){
     183                                        constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,DiagnosticHorizAnalysisEnum));
     184                                        count++;
     185                                }
     186
    178187                                if (!isnan(iomodel->spcvz[i]) && ((int)iomodel->vertices_type[i]==StokesApproximationEnum ||  ((int)iomodel->vertices_type[i]==NoneApproximationEnum))){
    179188                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,iomodel->spcvz[i]/iomodel->yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
  • TabularUnified issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp

    r9002 r9298  
    1212void SpcNodesx(Nodes* nodes,Constraints* constraints,Parameters* parameters, int analysis_type){
    1313
    14         int i;
    15                        
    16         for(i=0;i<constraints->Size();i++){
     14        for(int i=0;i<constraints->Size();i++){
    1715       
    1816                Constraint* constraint=(Constraint*)constraints->GetObjectByOffset(i);
  • TabularUnified issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp

    r9293 r9298  
    1010#include "../../EnumDefinitions/EnumDefinitions.h"
    1111
    12 void UpdateDynamicConstraintsx(Nodes* nodes,Parameters* parameters,Vec ys){
     12void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg){
    1313       
    14         int i;
    1514        int configuration_type;
    16         double* ys_serial=NULL;
     15        double* yg_serial=NULL;
    1716
    18         /*retrieve parameters: */
     17        /*Get current configuration*/
    1918        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
    2019
    21         if(nodes->NumberOfNodes(configuration_type)){
     20        /*serialize yg, so nodes can index into it: */
     21        VecToMPISerial(&yg_serial,yg);
    2222
    23                 /*serialize ys, so nodes can index into it: */
    24                 VecToMPISerial(&ys_serial,ys);
     23        for(int i=0;i<constraints->Size();i++){
    2524
    26                 /*Go through all nodes, and ask them to retrieve values from ys and then update their spc values :*/
    27                 for(i=0;i<nodes->Size();i++){
     25                Constraint* constraint=(Constraint*)constraints->GetObjectByOffset(i);
    2826
    29                         Node* node=(Node*)nodes->GetObjectByOffset(i);
     27                /*Check this constraint belongs to this analysis: */
     28                if(constraint->InAnalysis(configuration_type) && constraint->Enum()==SpcDynamicEnum){
    3029
    31                         /*Check that this node corresponds to our analysis currently being carried out: */
    32                         if (node->InAnalysis(configuration_type)){
     30                        ((SpcDynamic*)constraint)->SetDynamicConstraint(nodes,yg_serial);
    3331
    34                                 /*For this object, reset values of spc fields in the node: */
    35                                 node->UpdateSpcs(ys_serial);
    36                         }
    3732                }
    3833        }
    3934
    4035        /*Free ressources:*/
    41         xfree((void**)&ys_serial);
     36        xfree((void**)&yg_serial);
    4237}
  • TabularUnified issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h

    r9293 r9298  
    99#include "../../objects/objects.h"
    1010
    11 void UpdateDynamicConstraintsx(Nodes* nodes,Parameters* parameters,Vec ys);
     11void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg);
    1212
    1313#endif  /* _UPDATESPCSX_H */
  • TabularUnified issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp

    r9286 r9298  
    2424/*}}}1*/
    2525/*FUNCTION SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid,...){{{1*/
    26 SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid, int spc_dof,double spc_value,int spc_analysis_type){
     26SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid, int spc_dof,int spc_analysis_type){
    2727
    2828        sid=spc_sid;
    2929        nodeid=spc_nodeid;
    3030        dof=spc_dof;
    31         value=spc_value;
     31        value=0;
    3232        analysis_type=spc_analysis_type;
     33        isset=false;
    3334
    3435        return;
     
    5051        printf("   dof: %i\n",dof);
    5152        printf("   value: %g\n",value);
     53        printf("   isset: %s\n",isset?"true":"false");
    5254        printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
    5355        return;
     
    5759void SpcDynamic::DeepEcho(void){
    5860
    59         printf("SpcDynamic:\n");
    60         printf("   sid: %i\n",sid);
    61         printf("   nodeid: %i\n",nodeid);
    62         printf("   dof: %i\n",dof);
    63         printf("   value: %g\n",value);
    64         printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
     61        this->Echo();
    6562        return;
    6663}               
     
    9592        memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
    9693        memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
     94        memcpy(marshalled_dataset,&isset,sizeof(isset));marshalled_dataset+=sizeof(isset);
    9795        memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
    9896
     
    108106                +sizeof(dof)
    109107                +sizeof(value)
     108                +sizeof(isset)
    110109                +sizeof(analysis_type)
    111110                +sizeof(int); //sizeof(int) for enum type
     
    127126        memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
    128127        memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
     128        memcpy(&isset,marshalled_dataset,sizeof(isset));marshalled_dataset+=sizeof(isset);
    129129        memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
    130130
     
    164164        /*Apply constraint: */
    165165        if(node){ //in case the spc is dealing with a node on another cpu
     166
     167                /*We should first check that the value has been set... (test306)*/
    166168                node->ApplyConstraint(dof,value);
    167169        }
     
    183185/*FUNCTION SpcDynamic::GetValue {{{1*/
    184186double SpcDynamic::GetValue(){
     187        _assert_(this->isset);
    185188        _assert_(!isnan(value));
    186189        return value;
    187190}
    188191/*}}}1*/
     192/*FUNCTION SpcDynamic::SetDynamicConstraint {{{1*/
     193void SpcDynamic::SetDynamicConstraint(Nodes* nodes,double* yg_serial){
     194
     195        int pos;
     196
     197        Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
     198        pos=node->GetDof(dof,GsetEnum);
     199
     200        this->value=yg_serial[pos];
     201        this->isset=true;
     202}
     203/*}}}1*/
  • TabularUnified issm/trunk/src/c/objects/Constraints/SpcDynamic.h

    r9286 r9298  
    1919                int dof; /*!component*/
    2020                double value; /*value*/
     21                bool isset;
    2122                int analysis_type;
    2223
     
    2526                /*SpcDynamic constructors, destructors:{{{1*/
    2627                SpcDynamic();
    27                 SpcDynamic(int sid,int nodeid, int dof,double value,int analysis_type);
     28                SpcDynamic(int sid,int nodeid, int dof,int analysis_type);
    2829                ~SpcDynamic();
    2930                /*}}}*/
     
    4748                int    GetDof();
    4849                double GetValue();
     50                void   SetDynamicConstraint(Nodes* nodes,double *yg_serial);
    4951                /*}}}*/
    5052
  • TabularUnified issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp

    r9293 r9298  
    1010       
    1111        /*variables: */
    12         Vec yg=NULL;
    13         Vec ys=NULL;
    14         Nodes* nodes=NULL;
    15         int i;
     12        Vec    yg    = NULL;
     13        Nodes *nodes = NULL;
     14        int    i;
    1615
    1716        _printf_(VerboseSolution(),"%s\n","   updating boundary conditions...");
     
    2524        /*retrieve boundary conditions from element inputs :*/
    2625        GetSolutionFromInputsx( &yg, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,  femmodel->parameters);
    27         Reducevectorgtosx(&ys,yg,femmodel->nodes,femmodel->parameters);
    2826
    2927        /*update spcs using this new vector of constraints: */
    30         UpdateDynamicConstraintsx(femmodel->nodes,femmodel->parameters,ys);
     28        UpdateDynamicConstraintsx(femmodel->constraints,femmodel->nodes,femmodel->parameters,yg);
    3129
    3230        /*Free ressources:*/
    33         VecFree(&ys);
    3431        VecFree(&yg);
    3532}
  • TabularUnified issm/trunk/src/m/solutions/ResetBoundaryConditions.m

    r9293 r9298  
    1414        %recreate constraints vector for the current analysis
    1515        ug=GetSolutionFromInputs(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters);
    16         ys=Reducevectorgtos(ug,femmodel.nodes,femmodel.parameters);
    1716
    1817        %update values of spcs inside nodes
    19         femmodel.nodes=UpdateDynamicConstraints(femmodel.nodes,femmodel.parameters,ys);
     18        femmodel.nodes=UpdateDynamicConstraints(femmodel.constraints,femmodel.nodes,femmodel.parameters,ug);
  • TabularUnified issm/trunk/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp

    r9293 r9298  
    88
    99        /*input datasets: */
    10         Nodes* nodes=NULL;
    11         Parameters* parameters=NULL;
    12         Vec ys=NULL;
     10        Constraints *constraints = NULL;
     11        Nodes       *nodes       = NULL;
     12        Parameters  *parameters  = NULL;
     13        Vec          yg          = NULL;
    1314
    1415        /*Boot module: */
     
    1920
    2021        /*Input datasets: */
     22        FetchMatlabData((DataSet**)&constraints,CONSTRAINTSIN);
    2123        FetchMatlabData((DataSet**)&nodes,NODESIN);
    2224        FetchMatlabData((Parameters**)&parameters,PARAMETERS);
    23         FetchMatlabData(&ys,YS);
     25        FetchMatlabData(&yg,YS);
    2426       
    2527        /*!Generate internal degree of freedom numbers: */
    26         UpdateDynamicConstraintsx(nodes,parameters,ys);
     28        UpdateDynamicConstraintsx(constraints,nodes,parameters,yg);
    2729
    2830        /*write output datasets: */
     
    3032
    3133        /*Free ressources: */
     34        VecFree(&yg);
     35        delete constraints;
    3236        delete nodes;
    3337        delete parameters;
  • TabularUnified issm/trunk/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.h

    r9293 r9298  
    1717
    1818/* serial input macros: */
    19 #define NODESIN (mxArray*)prhs[0]
    20 #define PARAMETERS (mxArray*)prhs[1]
    21 #define YS (mxArray*)prhs[2]
     19#define CONSTRAINTSIN (mxArray*)prhs[0]
     20#define NODESIN (mxArray*)prhs[1]
     21#define PARAMETERS (mxArray*)prhs[2]
     22#define YS (mxArray*)prhs[3]
    2223
    2324/* serial output macros: */
     
    2829#define NLHS  1
    2930#undef NRHS
    30 #define NRHS  3
     31#define NRHS  4
    3132
    3233#endif  /* _UPDATESPCS_H */
Note: See TracChangeset for help on using the changeset viewer.