[3372] | 1 | /*!\file FieldAverageOntoVerticesx
|
---|
| 2 | * \brief: average field throfieldh thickness
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #include "./FieldAverageOntoVerticesx.h"
|
---|
| 6 |
|
---|
[3913] | 7 | #include "../../shared/shared.h"
|
---|
| 8 | #include "../../include/include.h"
|
---|
| 9 | #include "../../toolkits/toolkits.h"
|
---|
| 10 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
[3372] | 11 |
|
---|
[4218] | 12 | void FieldAverageOntoVerticesx(Vec* pfield, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
|
---|
[3372] | 13 |
|
---|
[3556] | 14 | /*Intermediary*/
|
---|
[3969] | 15 | int i;
|
---|
[3556] | 16 | int numberofvertices,found;
|
---|
| 17 | Vec connectivity=NULL;
|
---|
| 18 | Vec fieldsum=NULL;
|
---|
[3372] | 19 | double* field_serial=NULL;
|
---|
[3969] | 20 | Node* node=NULL;
|
---|
[3372] | 21 |
|
---|
[3556] | 22 | /*Output*/
|
---|
| 23 | Vec field=NULL;
|
---|
| 24 |
|
---|
[3869] | 25 | /*Initialize intermediary*/
|
---|
[4185] | 26 | numberofvertices=vertices->NumberOfVertices();
|
---|
[3556] | 27 | connectivity=NewVec(numberofvertices);
|
---|
| 28 | fieldsum =NewVec(numberofvertices);
|
---|
| 29 |
|
---|
[3372] | 30 | /*Serialize field: */
|
---|
[3556] | 31 | VecToMPISerial(&field_serial,*pfield);
|
---|
[3372] | 32 |
|
---|
[3556] | 33 | /*Compute summ of connectivity and summ of values: */
|
---|
[3969] | 34 | for (i=0;i<nodes->Size();i++){
|
---|
| 35 | node=(Node*)nodes->GetObjectByOffset(i);
|
---|
| 36 | node->FieldAverageOntoVertices(fieldsum,connectivity,field_serial);
|
---|
| 37 | }
|
---|
[3372] | 38 |
|
---|
[3556] | 39 | /*Assemble vectors: */
|
---|
| 40 | VecAssemblyBegin(connectivity);
|
---|
| 41 | VecAssemblyEnd(connectivity);
|
---|
| 42 | VecAssemblyBegin(fieldsum);
|
---|
| 43 | VecAssemblyEnd(fieldsum);
|
---|
[3372] | 44 |
|
---|
[3556] | 45 | /*Initialize output*/
|
---|
| 46 | field=NewVec(numberofvertices);
|
---|
| 47 |
|
---|
| 48 | /*Create Field = Fieldsum./connectivity */
|
---|
| 49 | VecPointwiseDivide(field,fieldsum,connectivity);
|
---|
| 50 |
|
---|
| 51 | /*Assign output pointer*/
|
---|
| 52 | VecFree(pfield);
|
---|
| 53 | *pfield=field;
|
---|
| 54 |
|
---|
[3372] | 55 | /*Free ressources:*/
|
---|
| 56 | xfree((void**)&field_serial);
|
---|
[3556] | 57 | VecFree(&connectivity);
|
---|
| 58 | VecFree(&fieldsum);
|
---|
[3372] | 59 |
|
---|
| 60 | }
|
---|