/[escript]/branches/domexper/dudley/src/Mesh_joinFaces.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/Mesh_joinFaces.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3126 - (show annotations)
Wed Sep 1 00:37:53 2010 UTC (8 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 4234 byte(s)
Updated referenceElements and enums
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
17 /* Dudley: Mesh */
18
19 /* detects faces in the mesh that match and replaces it by step elements */
20
21 /**************************************************************/
22
23 #include "Mesh.h"
24
25 /**************************************************************/
26
27 void Dudley_Mesh_joinFaces(Dudley_Mesh* self,double safety_factor,double tolerance, bool_t optimize) {
28
29 char error_msg[LenErrorMsg_MAX];
30 index_t *elem1=NULL,*elem0=NULL,*elem_mask=NULL,*matching_nodes_in_elem1=NULL;
31 Dudley_ElementFile *newFaceElementsFile=NULL;
32 dim_t e,numPairs, NN, new_numFaceElements;
33 Dudley_ReferenceElement* faceRefElement=NULL, *contactRefElement=NULL;
34
35 if (self->MPIInfo->size>1) {
36 Dudley_setError(TYPE_ERROR,"Dudley_Mesh_joinFaces: MPI is not supported yet.");
37 return;
38 }
39 if (self->FaceElements==NULL) return;
40 faceRefElement= Dudley_ReferenceElementSet_borrowReferenceElement(self->FaceElements->referenceElementSet, FALSE);
41
42 NN=self->FaceElements->numNodes;
43
44 if (faceRefElement->Type->numNodesOnFace<=0) {
45 sprintf(error_msg,"Dudley_Mesh_joinFaces:joining faces cannot be applied to face elements of type %s",faceRefElement->Type->Name);
46 Dudley_setError(TYPE_ERROR,error_msg);
47 return;
48 }
49
50
51 if (contactRefElement->Type->numNodes != 2*faceRefElement->Type->numNodes) {
52 sprintf(error_msg,"Dudley_Mesh_joinFaces:contact element file for %s need to hold elements created from face elements %s", contactRefElement->Type->Name,faceRefElement->Type->Name);
53 Dudley_setError(TYPE_ERROR,error_msg);
54 return;
55 }
56
57 /* allocate work arrays */
58 elem1=TMPMEMALLOC(self->FaceElements->numElements,index_t);
59 elem0=TMPMEMALLOC(self->FaceElements->numElements,index_t);
60 elem_mask=TMPMEMALLOC(self->FaceElements->numElements,index_t);
61 matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);
62
63 if (!(Dudley_checkPtr(elem1) || Dudley_checkPtr(elem0) || Dudley_checkPtr(elem_mask) || Dudley_checkPtr(matching_nodes_in_elem1))) {
64
65 /* find the matching face elements */
66 Dudley_Mesh_findMatchingFaces(self->Nodes,self->FaceElements,safety_factor,tolerance,&numPairs,elem0,elem1,matching_nodes_in_elem1);
67 if (Dudley_noError()) {
68 /* get a list of the face elements to be kept */
69 #pragma omp parallel for private(e) schedule(static)
70 for(e=0;e<self->FaceElements->numElements;e++) elem_mask[e]=1;
71 for(e=0;e<numPairs;e++) {
72 elem_mask[elem0[e]]=0;
73 elem_mask[elem1[e]]=0;
74 }
75 new_numFaceElements=0;
76 /* OMP */
77 for(e=0;e<self->FaceElements->numElements;e++) {
78 if (elem_mask[e]>0) {
79 elem_mask[new_numFaceElements]=e;
80 new_numFaceElements++;
81 }
82 }
83 /* allocate new face element file */
84 newFaceElementsFile=Dudley_ElementFile_alloc(self->FaceElements->referenceElementSet, self->MPIInfo);
85 if (Dudley_noError()) {
86 Dudley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
87 }
88 /* copy the old elements over */
89 if (Dudley_noError()) {
90 /* get the face elements which are still in use:*/
91 Dudley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
92 }
93 /* set new face and Contact elements */
94 if (Dudley_noError()) {
95
96 Dudley_ElementFile_free(self->FaceElements);
97 self->FaceElements=newFaceElementsFile;
98 Dudley_Mesh_prepare(self, optimize);
99
100 } else {
101 Dudley_ElementFile_free(newFaceElementsFile);
102 }
103 }
104 }
105 TMPMEMFREE(elem1);
106 TMPMEMFREE(elem0);
107 TMPMEMFREE(matching_nodes_in_elem1);
108 TMPMEMFREE(elem_mask);
109 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26