~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to dudley/src/NodeFile_setCoordinates.c

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*******************************************************
 
3
*
 
4
* Copyright (c) 2003-2010 by University of Queensland
 
5
* Earth Systems Science Computational Center (ESSCC)
 
6
* http://www.uq.edu.au/esscc
 
7
*
 
8
* Primary Business: Queensland, Australia
 
9
* Licensed under the Open Software License version 3.0
 
10
* http://www.opensource.org/licenses/osl-3.0.php
 
11
*
 
12
*******************************************************/
 
13
 
 
14
/**************************************************************/
 
15
 
 
16
/*   Dudley: Mesh: NodeFile */
 
17
 
 
18
/* copies the array newX into self->coordinates */
 
19
 
 
20
/**************************************************************/
 
21
 
 
22
#include "NodeFile.h"
 
23
#include "Util.h"
 
24
 
 
25
/**************************************************************/
 
26
 
 
27
void Dudley_NodeFile_setCoordinates(Dudley_NodeFile * self, escriptDataC * newX)
 
28
{
 
29
    char error_msg[LenErrorMsg_MAX];
 
30
    size_t numDim_size;
 
31
    int n;
 
32
    if (getDataPointSize(newX) != self->numDim)
 
33
    {
 
34
        sprintf(error_msg, "Dudley_NodeFile_setCoordinates: dimension of new coordinates has to be %d.", self->numDim);
 
35
        Dudley_setError(VALUE_ERROR, error_msg);
 
36
    }
 
37
    else if (!numSamplesEqual(newX, 1, self->numNodes))
 
38
    {
 
39
        sprintf(error_msg, "Dudley_NodeFile_setCoordinates: number of given nodes must to be %d.", self->numNodes);
 
40
        Dudley_setError(VALUE_ERROR, error_msg);
 
41
    }
 
42
    else
 
43
    {
 
44
        numDim_size = self->numDim * sizeof(double);
 
45
        Dudley_increaseStatus(self);
 
46
#pragma omp parallel private(n)
 
47
        {
 
48
 
 
49
#pragma omp for schedule(static)
 
50
            for (n = 0; n < self->numNodes; n++)
 
51
            {
 
52
                memcpy(&(self->Coordinates[INDEX2(0, n, self->numDim)]), getSampleDataROFast(newX, n), numDim_size);
 
53
            }
 
54
        }
 
55
    }
 
56
}