| 1 | /*
|
|---|
| 2 | * CreateConstraintsEnthalpy.c:
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #include "../../../Container/Container.h"
|
|---|
| 6 | #include "../../../io/io.h"
|
|---|
| 7 | #include "../../../toolkits/toolkits.h"
|
|---|
| 8 | #include "../../../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 9 | #include "../../../objects/objects.h"
|
|---|
| 10 | #include "../../../shared/shared.h"
|
|---|
| 11 | #include "../ModelProcessorx.h"
|
|---|
| 12 |
|
|---|
| 13 | void CreateConstraintsEnthalpy(Constraints** pconstraints, IoModel* iomodel){
|
|---|
| 14 |
|
|---|
| 15 | /*Intermediary*/
|
|---|
| 16 | int i;
|
|---|
| 17 | int count;
|
|---|
| 18 | int dim;
|
|---|
| 19 | int numberofvertices;
|
|---|
| 20 | double heatcapacity;
|
|---|
| 21 | double referencetemperature;
|
|---|
| 22 |
|
|---|
| 23 | /*Output*/
|
|---|
| 24 | Constraints* constraints = NULL;
|
|---|
| 25 | SpcStatic* spcstatic = NULL;
|
|---|
| 26 |
|
|---|
| 27 | /*Fetch parameters: */
|
|---|
| 28 | iomodel->parameters->FindParam(&dim,DimEnum);
|
|---|
| 29 | iomodel->parameters->FindParam(&numberofvertices,NumberOfVerticesEnum);
|
|---|
| 30 | iomodel->parameters->FindParam(&heatcapacity,HeatcapacityEnum);
|
|---|
| 31 | iomodel->parameters->FindParam(&referencetemperature,ReferencetemperatureEnum);
|
|---|
| 32 |
|
|---|
| 33 | /*Recover pointer: */
|
|---|
| 34 | constraints=*pconstraints;
|
|---|
| 35 |
|
|---|
| 36 | /*Create constraints if they do not exist yet*/
|
|---|
| 37 | if(!constraints) constraints = new Constraints(ConstraintsEnum);
|
|---|
| 38 |
|
|---|
| 39 | /*return if 2d mesh*/
|
|---|
| 40 | if (dim==2) goto cleanup_and_return;
|
|---|
| 41 |
|
|---|
| 42 | /*Fetch data: */
|
|---|
| 43 | iomodel->FetchData(&iomodel->spctemperature,NULL,NULL,SpctemperatureEnum);
|
|---|
| 44 |
|
|---|
| 45 | /*Initialize counter*/
|
|---|
| 46 | count=0;
|
|---|
| 47 |
|
|---|
| 48 | /*Create constraints from x,y,z: */
|
|---|
| 49 | for (i=0;i<numberofvertices;i++){
|
|---|
| 50 | /*keep only this partition's nodes:*/
|
|---|
| 51 | if((iomodel->my_vertices[i])){
|
|---|
| 52 |
|
|---|
| 53 | if ((int)iomodel->spctemperature[2*i]){
|
|---|
| 54 |
|
|---|
| 55 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(iomodel->spctemperature[2*i+1]-referencetemperature),EnthalpyAnalysisEnum));
|
|---|
| 56 | count++;
|
|---|
| 57 |
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /*Free data: */
|
|---|
| 63 | xfree((void**)&iomodel->spctemperature);
|
|---|
| 64 |
|
|---|
| 65 | cleanup_and_return:
|
|---|
| 66 |
|
|---|
| 67 | /*Assign output pointer: */
|
|---|
| 68 | *pconstraints=constraints;
|
|---|
| 69 | }
|
|---|