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->constants->FindParam(&dim,DimEnum);
|
---|
29 | iomodel->constants->FindParam(&numberofvertices,NumberOfVerticesEnum);
|
---|
30 | iomodel->constants->FindParam(&heatcapacity,HeatcapacityEnum);
|
---|
31 | iomodel->constants->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){
|
---|
41 | *pconstraints=constraints;
|
---|
42 | return;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /*Fetch data: */
|
---|
46 | double *spctemperature=NULL;
|
---|
47 | iomodel->FetchData(&spctemperature,NULL,NULL,SpctemperatureEnum);
|
---|
48 |
|
---|
49 | /*Initialize counter*/
|
---|
50 | count=0;
|
---|
51 |
|
---|
52 | /*Create constraints from x,y,z: */
|
---|
53 | for (i=0;i<numberofvertices;i++){
|
---|
54 | /*keep only this partition's nodes:*/
|
---|
55 | if((iomodel->my_vertices[i])){
|
---|
56 |
|
---|
57 | if ((int)spctemperature[2*i]){
|
---|
58 |
|
---|
59 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[2*i+1]-referencetemperature),EnthalpyAnalysisEnum));
|
---|
60 | count++;
|
---|
61 |
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*Free data: */
|
---|
67 | xfree((void**)&spctemperature);
|
---|
68 |
|
---|
69 | /*Assign output pointer: */
|
---|
70 | *pconstraints=constraints;
|
---|
71 | }
|
---|