BNDP* BNDP_CreateBndP (HEAP *Heap, BNDP *theBndP0, BNDP *theBndP1, DOUBLE lcoord) { BP *bp; BP *b0 = (BP *) theBndP0; BP *b1 = (BP *) theBndP1; INT k; INT n = CountCommonSegments(b0,b1); ASSERT(n>0); bp = (BP *) GetFreelistMemory(Heap,sizeof(BP)+(n-1)*sizeof(int)); ASSERT(bp != NULL); bp->n = CommonSegments(b0,b1,bp->segment); bp->id = 0; for (k=0; k<DIM; k++) bp->x[k] = (1.0 - lcoord) * b0->x[k] + lcoord * b1->x[k]; if (Geom != NULL) Geom(bp->segment[0],b0->x,b1->x,lcoord,bp->x); if (Prop == NULL) bp->property = 0; else bp->property = Prop(bp->segment[0]); return((BNDP *)bp); }
BNDP* BNDS_CreateBndP (HEAP *Heap, BNDS *theBndS, DOUBLE *local) { BS *bs = (BS *) theBndS; BP *bp = (BP *) GetFreelistMemory(Heap,sizeof(BP)); ASSERT(bp != NULL); BNDS_Global(theBndS,local,bp->x); bp->id = bs->id; bp->n = 1; bp->segment[0] = bs->segment; bp->property = bs->property; return((BNDP *)bp); }
BNDP *BNDP_LoadBndP (BVP *theBVP, HEAP *Heap) { BP *p; INT j; int iList[3+MAX_SEGMENTS]; double dList[DIM]; if (Bio_Read_mint(3,iList)) return (NULL); p = (BP *) GetFreelistMemory(Heap,sizeof(BP)+(iList[2]-1)*sizeof(int)); p->id = iList[0]; p->property = iList[1]; p->n = iList[2]; if (Bio_Read_mint(p->n,iList)) return (NULL); for (j=0; j<p->n; j++) p->segment[j] = iList[j]; if (Bio_Read_mdouble(DIM,dList)) return (NULL); for (j=0; j<DIM; j++) p->x[j] = dList[j]; return((BNDP *)p); }
BNDS* BNDP_CreateBndS (HEAP *Heap, BNDP **theBndP, INT n) { BS *bs = (BS *) GetFreelistMemory(Heap,sizeof(BS)); BP **bp = (BP **) theBndP; INT j,k; ASSERT(bs != NULL); bs->n = n; bs->id = 0; bs->segment = 0; bs->segment = FindSegment(n,bp); if (Prop == NULL) bs->property = 0; else bs->property = Prop(bs->segment); for (j=0; j<n; j++) for (k=0; k<DIM; k++) bs->x[j][k] = bp[j]->x[k]; return((BNDS *)bs); }
INT InitGeometry (HEAP *Heap, GEOMETRY *G) { INT i; for (i=0; i<G->nP; i++) if (G->P[i].bnd == 1) { int k,n; if (G->P[i].segment <G->nS) n = 1; else n = G->L[G->P[i].segment-G->nS].n; ASSERT(n>0); G->P[i].bp = (BP *) GetFreelistMemory(Heap,sizeof(BP)+(n-1)*sizeof(int)); ASSERT(G->P[i].bp != NULL); G->P[i].bp->id = G->P[i].id; G->P[i].bp->n = n; if (n == 1) G->P[i].bp->segment[0] = G->P[i].segment; else for (k=0; k<n; k++) G->P[i].bp->segment[k] = G->L[G->P[i].segment-G->nS].S[k]; G->P[i].bp->property = 0; for (k=0; k<DIM; k++) G->P[i].bp->x[k] = G->P[i].x[k]; } for (i=0; i<G->nC; i++) if (G->C[i].bnd == 1) { int j; for (j=0; j<nfaces[G->C[i].n]; j++) { if (G->C[i].C[j] < 0) { int k; int in = G->S[G->C[i].S[j]].in; int out = G->S[G->C[i].S[j]].out; G->C[i].bs[j] = (BS *) GetFreelistMemory(Heap,sizeof(BS)); ASSERT(G->C[i].bs[j] != NULL); G->C[i].bs[j]->id = G->F[G->C[i].F[j]].id; G->C[i].bs[j]->in = G->C[i].subdomain; if (G->C[i].subdomain == in) G->C[i].bs[j]->out = out; else G->C[i].bs[j]->out = in; G->C[i].bs[j]->segment = G->C[i].S[j]; G->C[i].bs[j]->property = G->S[G->C[i].S[j]].property; G->C[i].bs[j]->n = ncfaces[G->C[i].n][j]; for (k=0; k<G->C[i].bs[j]->n; k++) { int l; for (l=0; l<DIM; l++) G->C[i].bs[j]->x[k][l] = G->P[G->C[i].P[faces[G->C[i].n][j][k]]].x[l]; } PRINTDEBUG(dom,3,("bs C %d F %d S %d prop %d\n", i,j, G->C[i].bs[j]->segment, G->S[G->C[i].S[j]].property)); } else G->C[i].bs[j] = NULL; } } Prop = G->Prop; Geom = G->Geom; return (0); }
/* domain interface function: for description see domain.h */ BVP* NS_DIM_PREFIX BVP_Init (const char *name, HEAP *Heap, MESH *Mesh, INT MarkKey) { LGM_DOMAIN *theDomain; LGM_PROBLEM *theProblem; BndCondProcPtr BndCond,InnerBndCond; INT i,nSubDom,conf_df_problem; char **argv; if ((theDomain = (LGM_DOMAIN *)BVP_GetByName(name))==NULL) { if ((theDomain = LGM_LoadDomain(name,name,Heap,theLGMDomainVarID,MarkKey))==NULL) { UserWriteF("ERROR in BVP_Init: cannot load domain '%s'\n",name); return (NULL); } /* set problem */ theProblem = Lgm_Problem_GetByName(LGM_DOMAIN_PROBLEMNAME(theDomain)); conf_df_problem = 0; if (theProblem==NULL) { theProblem = Lgm_Problem_GetByName("configurable"); if (theProblem==NULL) { UserWrite("ERROR in BVP_Init: cannot find problem\n"); return (NULL); } conf_df_problem = 1; } LGM_DOMAIN_PROBLEM(theDomain) = theProblem; /* initialize problem */ if (conf_df_problem) { INT maxLineId = 0; if (theProblem->InitProblem==NULL) return (NULL); nSubDom = LGM_DOMAIN_NSUBDOM(theDomain); argv = (char **) GetTmpMem(Heap, sizeof(char *)*(nSubDom+1),MarkKey); if (argv==NULL) { UserWrite("ERROR in BVP_Init: cannot allocate argv\n"); return (NULL); } for(i=1; i<=nSubDom; i++) { LGM_SUBDOMAIN *subdom = LGM_DOMAIN_SUBDOM(theDomain,i); argv[i] = LGM_SUBDOMAIN_UNIT(subdom); } /* get maximum Line/Surface-Id */ maxLineId = GetMaximumSurfaceID(theDomain); if ((*(theProblem->InitProblem))(nSubDom, argv, maxLineId+1, LGM_DOMAIN_PROBLEMNAME(theDomain), Heap)) { UserWrite("ERROR in BVP_Init: cannot initialize problem\n"); return (NULL); } } /* set boundary conditions */ BndCond = LGM_PROBLEM_BNDCOND(theProblem); InnerBndCond = LGM_PROBLEM_INNERBNDCOND(theProblem); if (SetBoundaryCondition(theDomain,BndCond,InnerBndCond)) return (NULL); } /* set bounding sphere */ if (SetDomainSize(theDomain)) return (NULL); /* set mesh with nothing */ if (Mesh!=NULL && LGM_LoadMesh(name, Heap,Mesh,theDomain,MarkKey)) { Mesh->mesh_status = MESHSTAT_EMPTY; Mesh->nBndP = 0; Mesh->nInnP = 0; Mesh->nSubDomains = 0; Mesh->nbElements = NULL; Mesh->nElements = NULL; Mesh->VertexLevel = NULL; Mesh->VertexPrio = NULL; Mesh->ElementLevel = NULL; Mesh->ElementPrio = NULL; Mesh->ElemSideOnBnd = NULL; } /* allocate s2p table */ LGM_DOMAIN_NPART(theDomain) = 1; LGM_DOMAIN_S2P_PTR(theDomain) = (INT*)GetFreelistMemory(Heap,(LGM_DOMAIN_NSUBDOM(theDomain)+1)*sizeof(INT)); if (LGM_DOMAIN_S2P_PTR(theDomain)==NULL) return (NULL); /* HRR_TODO: fill number of parts */ for (i=0; i<=LGM_DOMAIN_NSUBDOM(theDomain); i++) LGM_DOMAIN_S2P(theDomain,i) = 0; theDomain->theHeap = Heap; return ((BVP *)theDomain); }