diff --git a/Code/C/fem/constraint.c b/Code/C/fem/constraint.c new file mode 100644 index 0000000..8316f56 --- /dev/null +++ b/Code/C/fem/constraint.c @@ -0,0 +1,17 @@ +#include +#include "constraint.h" + +void constraintPrint(Constraint *theConstraint){ + printf("Constraint No. : %d \n", theConstraint->tag); + printf("Node No. : %d \n", theConstraint->NodeTag); + printf("Constraint: %d %d %d \n", theConstraint->DOF[0], theConstraint->DOF[1], theConstraint->DOF[2]); +} + +void constraintSetup(Constraint *theConstraint, int tag, int NodeTag, int DOF1, int DOF2, int DOF3) { + theConstraint->tag = tag; + theConstraint->NodeTag = NodeTag; + theConstraint->DOF[0] = DOF1; + theConstraint->DOF[1] = DOF2; + theConstraint->DOF[2] = DOF3; + theConstraint->next = NULL; +} diff --git a/Code/C/fem/constraint.h b/Code/C/fem/constraint.h new file mode 100644 index 0000000..c5258ba --- /dev/null +++ b/Code/C/fem/constraint.h @@ -0,0 +1,17 @@ +#ifndef _CONSTRAINT //if no definition for "_CONSTRAINT" +#define _CONSTRAINT +//preventing the compiler from loading it again if multiple reference to this file exists. + +#include + +typedef struct constraint { + int tag; + int NodeTag; + int DOF[3]; + struct constraint *next; +} Constraint; + +void constraintPrint(Constraint *); +void constraintSetup(Constraint *, int tag, int NodeTag, int DOF1, int DOF2, int DOF3); + +#endif diff --git a/Code/C/fem/domain.c b/Code/C/fem/domain.c index ffb8052..e2770bd 100644 --- a/Code/C/fem/domain.c +++ b/Code/C/fem/domain.c @@ -6,6 +6,7 @@ void domainPrint(Domain *theDomain) { printf("The Nodes:\n"); domainPrintNodes(theDomain); + domainPrintConstraint(theDomain); } void domainAddNode(Domain *theDomain, int tag, double crd1, double crd2) { @@ -17,6 +18,7 @@ void domainAddNode(Domain *theDomain, int tag, double crd1, double crd2) { } else { theNextNode->next = NULL; } + theDomain->theNodes = theNextNode; } @@ -32,10 +34,45 @@ Node *domainGetNode(Domain *theDomain, int nodeTag) { Node *theCurrentNode = theDomain->theNodes; while (theCurrentNode != NULL) { if (theCurrentNode->tag == nodeTag) { - return theCurrentNode; + return theCurrentNode; //return gets out of the program } else { theCurrentNode = theCurrentNode->next; } }; return NULL; } + + +void domainAddConstraint(Domain *theDomain, int tag, int NodeTag, int DOF1, int DOF2, int DOF3) { + Constraint *theNextConstraint = (Constraint *)malloc(sizeof(Constraint)); + constraintSetup(theNextConstraint, tag, NodeTag, DOF1, DOF2, DOF3); + + if (theDomain->theConstraints != NULL) { + theNextConstraint->next = theDomain->theConstraints; + + } else { + theNextConstraint->next = NULL; + } + + theDomain->theConstraints = theNextConstraint; +} + +void domainPrintConstraint(Domain *theDomain) { + Constraint *theCurrentConstraint = theDomain->theConstraints; + while (theCurrentConstraint != NULL) { + constraintPrint(theCurrentConstraint); + theCurrentConstraint = theCurrentConstraint->next; + }; +} + +Constraint *domainGetConstraint(Domain *theDomain, int constraintTag) { + Constraint *theCurrentConstraint = theDomain->theConstraints; + while (theCurrentConstraint != NULL) { + if (theCurrentConstraint->tag == constraintTag) { + return theCurrentConstraint; //return gets out of the program + } else { + theCurrentConstraint = theCurrentConstraint->next; + } + }; + return NULL; +} diff --git a/Code/C/fem/domain.h b/Code/C/fem/domain.h index 29151ec..1d70de7 100644 --- a/Code/C/fem/domain.h +++ b/Code/C/fem/domain.h @@ -1,11 +1,19 @@ #include "node.h" +#include "constraint.h" typedef struct struct_domain { Node *theNodes; + Constraint *theConstraints; + } Domain; void domainPrint(Domain *theDomain); + void domainAddNode(Domain *theDomain, int tag, double crd1, double crd2); void domainPrintNodes(Domain *theDomain); Node *domainGetNode(Domain *, int nodeTag); +void domainAddConstraint(Domain *theDomain, int tag, int NodeTag, int DOF1, int DOF2, int DOF3); +void domainPrintConstraint(Domain *theDomain); +Constraint *domainGetConstraint(Domain *, int constaintTag); + diff --git a/Code/C/fem/domain1.c b/Code/C/fem/domain1.c new file mode 100644 index 0000000..bc2f75a --- /dev/null +++ b/Code/C/fem/domain1.c @@ -0,0 +1,79 @@ +#include +#include +#include "domain.h" +#include "node.h" + +void domainPrint(Domain *theDomain) { + printf("The Nodes:\n"); + domainPrintNodes(theDomain); + domainPrintConstraint(theDomain); +} + +void domainAddNode(Domain *theDomain, int tag, double crd1, double crd2) { + Node *theNextNode = (Node *)malloc(sizeof(Node)); + nodeSetup(theNextNode, tag, crd1, crd2); + + if (theDomain->theNodes != NULL) { + theNextNode->next = theDomain->theNodes; + + } else { + theNextNode->next = NULL; + } + + theDomain->theNodes = theNextNode; +} + +void domainPrintNodes(Domain *theDomain) { + Node *theCurrentNode = theDomain->theNodes; + while (theCurrentNode != NULL) { + nodePrint(theCurrentNode); + theCurrentNode = theCurrentNode->next; + }; +} + +Node *domainGetNode(Domain *theDomain, int nodeTag) { + Node *theCurrentNode = theDomain->theNodes; + while (theCurrentNode != NULL) { + if (theCurrentNode->tag == nodeTag) { + return theCurrentNode; //return gets out of the program + } else { + theCurrentNode = theCurrentNode->next; + } + }; + return NULL; +} + + +void domainAddConstraint(Domain *theDomain, int tag, int NodeTag, int DOF1, int DOF2, int DOF3) { + Constraint *theNextConstraint = (Constraint *)malloc(sizeof(Constraint)); + constraintSetup(theNextConstraint, tag, NodeTag, DOF1, DOF2, DOF3); + + if (theDomain->theConstraints != NULL) { + theNextConstraint->next = theDomain->theConstraints; + + } else { + theNextConstraint->next = NULL; + } + + theDomain->theConstraints = theNextConstraint; +} + +void domainPrintConstraint(Domain *theDomain) { + Constraint *theCurrentConstraint = theDomain->theConstraints; + while (theCurrentConstraint != NULL) { + constraintPrint(theCurrentConstraint); + theCurrentConstraint = theCurrentConstraint->next; + }; +} + +Constraint *domainGetConstraint(Domain *theDomain, int constraintTag) { + Constraint *theCurrentConstraint = theDomain->theConstraints; + while (theCurrentConstraint != NULL) { + if (theCurrentConstraint->tag == constraintTag) { + return theCurrentConstraint; //return gets out of the program + } else { + theCurrentConstraint = theCurrentConstraint->next; + } + }; + return NULL; +} diff --git a/Code/C/fem/domain1.h b/Code/C/fem/domain1.h new file mode 100644 index 0000000..1d70de7 --- /dev/null +++ b/Code/C/fem/domain1.h @@ -0,0 +1,19 @@ +#include "node.h" +#include "constraint.h" + +typedef struct struct_domain { + Node *theNodes; + Constraint *theConstraints; + +} Domain; + +void domainPrint(Domain *theDomain); + +void domainAddNode(Domain *theDomain, int tag, double crd1, double crd2); +void domainPrintNodes(Domain *theDomain); +Node *domainGetNode(Domain *, int nodeTag); + +void domainAddConstraint(Domain *theDomain, int tag, int NodeTag, int DOF1, int DOF2, int DOF3); +void domainPrintConstraint(Domain *theDomain); +Constraint *domainGetConstraint(Domain *, int constaintTag); + diff --git a/Code/C/fem/main.c b/Code/C/fem/main.c index 6242353..9a3a7c8 100644 --- a/Code/C/fem/main.c +++ b/Code/C/fem/main.c @@ -1,17 +1,29 @@ #include "node.h" #include "domain.h" +#include "constraint.h" int main(int argc, char **argv) { Domain theDomain; + theDomain.theNodes=0; + domainAddNode(&theDomain, 1, 0.0, 0.0); domainAddNode(&theDomain, 2, 0.0, 2.0); domainAddNode(&theDomain, 3, 1.0, 1.0); + theDomain.theConstraints = 0; + domainAddConstraint(&theDomain, 1, 1, 1,1,1); + domainAddConstraint(&theDomain, 2, 3, 1,0,0); + domainPrint(&theDomain); // get and print singular node printf("\nsingular node:\n"); Node *theNode = domainGetNode(&theDomain, 2); nodePrint(theNode); + + // get and print constraints + printf("\nconstraints:\n"); + Constraint *theConstraint = domainGetConstraint(&theDomain, 1); + constraintPrint(theConstraint); } diff --git a/Code/C/fem/main1.c b/Code/C/fem/main1.c new file mode 100644 index 0000000..ab0664d --- /dev/null +++ b/Code/C/fem/main1.c @@ -0,0 +1,28 @@ +#include "node.h" +#include "domain.h" +#include "constraint.h" + +int main(int argc, char **argv) { + Domain theDomain; + + theDomain.theNodes = 0; //initialize the pointers + domainAddNode(&theDomain, 1, 0.0, 0.0); + domainAddNode(&theDomain, 2, 0.0, 2.0); + domainAddNode(&theDomain, 3, 1.0, 1.0); + + theDomain.theConstraints = 0; + domainAddConstraint(&theDomain, 1, 1, 1,1,1); + domainAddConstraint(&theDomain, 2, 3, 1,0,0); + + domainPrint(&theDomain); + + // get and print singular node + printf("\nsingular node:\n"); + Node *theNode = domainGetNode(&theDomain, 2); + nodePrint(theNode); + + // get and print constraints + printf("\nconstraints:\n"); + Constraint *theConstraint = domainGetConstraint(&theDomain, 1); + constraintPrint(theConstraint); +} diff --git a/Code/Parallel/mpi/pi_numeric_integration_parallel.cpp b/Code/Parallel/mpi/pi_numeric_integration_parallel.cpp new file mode 100644 index 0000000..a78040d --- /dev/null +++ b/Code/Parallel/mpi/pi_numeric_integration_parallel.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#define LUMP 5 + +using namespace std; + +static int long numSteps=100000; + +int main(int argc, char **argv) { + + int numP, procID; + + double pi=0, time=0; + + clock_t start; //timer + start = std::clock(); + //cout< +#include +#include +//#include +#include +#include + +using namespace std; + +static int long numSteps=100000; + +int main(int argc, char **argv) { + + int numP, procID; + + double pi=0, time1, time2; + + //clock_t start; //timer + time1 = omp_get_wtime(); + //start = std::clock(); + //cout< +#include +//#include +//#include +//#include +#include +//#include + +//using namespace std; + +static int long numSteps=1000000000; + +int main(int argc, char **argv) { + + int numP, procID; + + double pi=0, time1, time2; + + //clock_t start; //timer + time1 = omp_get_wtime(); + //start = std::clock(); + //cout< +#include +#include +#include +#include + +using namespace std; + + +static int long numSteps=100000; +int main() { + double pi=0, time=0; + + clock_t start; //timer + start = std::clock(); + //cout<