⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_constraintofelement.c

📁 cfd求解器使用与gmsh网格的求解
💻 C
📖 第 1 页 / 共 3 页
字号:
#define RCSID "$Id: Get_ConstraintOfElement.c,v 1.31 2006/02/26 00:42:54 geuzaine Exp $"/* * Copyright (C) 1997-2006 P. Dular, C. Geuzaine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Please report all bugs and problems to <getdp@geuz.org>. */#include "GetDP.h"#include "Get_DofOfElement.h"#include "ExtendedGroup.h"#include "Cal_Quantity.h"#include "GeoData.h"#include "CurrentData.h"#include "Tools.h"extern int  Nbr_ElementaryBF ;/* ------------------------------------------------------------------------ *//*  T r e a t m e n t _ C o n s t r a i n t F o r E l e m e n t             *//* ------------------------------------------------------------------------ */void  Treatment_ConstraintForElement(struct FunctionSpace    * FunctionSpace_P,				     struct QuantityStorage  * QuantityStorage_P,				     int Num_Entity[], int i_Entity,				     int i_BFunction, int TypeConstraint) {  int                    Nbr_Constraint, i_Constraint, k, Index_GeoElement, dummy ;  double                *uvw;  List_T                      * Constraint_L ;  struct ConstraintInFS       * Constraint_P ;  struct ConstraintPerRegion  * ConstraintPerRegion_P ;  struct GlobalQuantity       * GlobalQuantity_P ;  struct Group                * GroupEntity_Pr ;  GetDP_Begin("Treatment_ConstraintForElement");  QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint = NONE ;  Constraint_L = FunctionSpace_P->Constraint ;  Nbr_Constraint = List_Nbr(Constraint_L) ;    for (i_Constraint = 0 ;       i_Constraint < Nbr_Constraint &&	 ! QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint ;       i_Constraint++) {        Constraint_P =      (struct ConstraintInFS*)List_Pointer(Constraint_L, i_Constraint) ;    ConstraintPerRegion_P = Constraint_P->ConstraintPerRegion ;    switch(ConstraintPerRegion_P->Type) {	    case ASSIGN :                case INIT :    case ASSIGNFROMRESOLUTION :  case INITFROMRESOLUTION :    case CST_LINK : case CST_LINKCPLX :	      switch(Constraint_P->QuantityType) {      case LOCALQUANTITY :	if(Constraint_P->ReferenceIndex == i_BFunction) {	  GroupEntity_Pr = (struct Group*)	    List_Pointer(Problem_S.Group, Constraint_P->EntityIndex) ;	  if(Check_IsEntityInExtendedGroup(GroupEntity_Pr,					   abs(Num_Entity[i_Entity]), 1)) {	    QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint =	      ConstraintPerRegion_P->Type ;	    if (ConstraintPerRegion_P->Type == ASSIGN ||		ConstraintPerRegion_P->Type == INIT) {	      switch (TypeConstraint) {	      case NODESOF :  	      case GROUPSOFEDGESONNODESOF :		Current.NumEntity = abs(Num_Entity[i_Entity]) ;		Geo_GetNodesCoordinates( 1, &Current.NumEntity,					 &Current.x, &Current.y, &Current.z) ;		/* This is necessary if we want CoordXYZ[] functions		   to work in prepro for nodal contraints */		uvw = Geo_GetNodes_uvw(Current.Element->Type, &dummy) ;		Current.u = uvw[3 * i_Entity] ;		Current.v = uvw[3 * i_Entity + 1] ;		Current.w = uvw[3 * i_Entity + 2] ;		break ;	      case EDGESOF :		Current.NumEntityInElement = i_Entity ;  		break ;	      }	      Get_ValueForConstraint		(Constraint_P,		 QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Value,		 &QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		 TimeFunctionIndex) ;	    }	    else if (ConstraintPerRegion_P->Type == CST_LINK ||		     ConstraintPerRegion_P->Type == CST_LINKCPLX) {	      Get_LinkForConstraint		(Constraint_P,		 abs(Num_Entity[i_Entity]),		 &QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		 CodeEntity_Link,		 QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Value) ;	      if (abs(Num_Entity[i_Entity]) ==		  QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		  CodeEntity_Link)		QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint =		  NONE ; /* Code linked with itself not allowed */	    }	    else {	      Get_PreResolutionForConstraint		(Constraint_P,		 &QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		 TimeFunctionIndex) ;	    }	  }	}	break ; /* LOCALQUANTITY */	      case GLOBALQUANTITY :		GlobalQuantity_P = (struct GlobalQuantity*)	  List_Pointer(FunctionSpace_P->GlobalQuantity,		       Constraint_P->ReferenceIndex) ;	if ((GlobalQuantity_P->Type == ALIASOF) &&	    (GlobalQuantity_P->ReferenceIndex == i_BFunction)) {    	  GroupEntity_Pr = (struct Group*)	    List_Pointer(Problem_S.Group, Constraint_P->EntityIndex) ;	  	  if (List_Search(GroupEntity_Pr->InitialList,			  &Num_Entity[i_Entity], fcmp_int)) {	    	    QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint =	      ConstraintPerRegion_P->Type ;	    if (ConstraintPerRegion_P->Type == ASSIGN ||		ConstraintPerRegion_P->Type == INIT) {	      Get_ValueForConstraint		(Constraint_P,		 QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Value,		 &QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		 TimeFunctionIndex) ;	    }	    else if (ConstraintPerRegion_P->Type == CST_LINK ||		     ConstraintPerRegion_P->Type == CST_LINKCPLX) {	      Msg(GERROR, "CST_LINK for GlobalQuantity not done yet") ;	    }	    else {	      Get_PreResolutionForConstraint		(Constraint_P,		 &QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].		 TimeFunctionIndex) ;	    }	  }	}			break ; /* GLOBALQUANTITY */      default :	Msg(GERROR, "Unknown type of Quantity in Constraint of type Fixed");	break;      }            break ;  /* ASSIGN || INIT || ASSIGNFROMRESOLUTION || INITFROMRESOLUTION */    default :      Msg(GERROR, "Unknown type of Constraint");      break;    }      }  /* for i_Constraint ... */  /* Constraints due to P-refinement */  if(Current.GeoData->P) {    Index_GeoElement = Geo_GetGeoElementIndex(Current.Element->GeoElement) ;    if (Current.GeoData->P[Index_GeoElement+1] >= 0 &&	Current.GeoData->P[Index_GeoElement+1] < 	QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].BasisFunction->Order){      QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Constraint = ASSIGN ;      for (k = 0 ; k < Current.NbrHar ; k++)	QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].Value[k] = 0. ;      QuantityStorage_P->BasisFunction[Nbr_ElementaryBF].TimeFunctionIndex = -1 ;    }  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  G e t _ V a l u e F o r C o n s t r a i n t                             *//* ------------------------------------------------------------------------ */void  Get_ValueForConstraint(struct ConstraintInFS * Constraint_P, double Value[],			     int * Index_TimeFunction) {  int  k ;  struct Value  Val_Modulus, Val_TimeFunction ;  GetDP_Begin("Get_ValueForConstraint");  /* Attention: u,v,w et x,y,z == 0 ! */  /* Il faudra changer ca. Pour le moment, on repose sur Current.x|y|z  */  Get_ValueOfExpression    ((struct Expression *)     List_Pointer(Problem_S.Expression,		  Constraint_P->ConstraintPerRegion->Case.Fixed.ExpressionIndex),     NULL, 0., 0., 0., &Val_Modulus) ;  *Index_TimeFunction = Constraint_P->ConstraintPerRegion->TimeFunctionIndex ;  if (Current.NbrHar > 1) {    if (*Index_TimeFunction >= 0) {      Get_ValueOfExpression	((struct Expression *)	 List_Pointer(Problem_S.Expression,		      Constraint_P->ConstraintPerRegion->TimeFunctionIndex),	 	 NULL, 0., 0., 0., &Val_TimeFunction) ;      Cal_ProductValue(&Val_Modulus, &Val_TimeFunction,  &Val_Modulus) ;    }    for (k = 0 ; k < Current.NbrHar ; k++)      Value[k] = Val_Modulus.Val[MAX_DIM*k] ;  }  else{    Value[0] = Val_Modulus.Val[0] ;  }  GetDP_End ;}/* ------------------------------------------------------------------------ *//*  T r e a t m e n t _ C o n s t r a i n t F o r R e g i o n               *//* ------------------------------------------------------------------------ */void  Treatment_ConstraintForRegion(struct GlobalQuantity   * GlobalQuantity_P,				    struct FunctionSpace    * FunctionSpace_P,				    struct QuantityStorage  * QuantityStorage_P) {  int                     Nbr_Constraint, i_Constraint ;  List_T                      * Constraint_L ;  struct ConstraintInFS       * Constraint_P ;  struct ConstraintPerRegion  * ConstraintPerRegion_P ;  struct Group                * GroupEntity_Pr ;  struct GlobalQuantity       * GlobalQuantity_Pr ;  GetDP_Begin("Treatment_ConstraintForRegion");  QuantityStorage_P->BasisFunction[0].Constraint = NONE ;  Constraint_L = FunctionSpace_P->Constraint ;  Nbr_Constraint = List_Nbr(Constraint_L) ;    for (i_Constraint = 0 ;       i_Constraint < Nbr_Constraint &&	 ! QuantityStorage_P->BasisFunction[0].Constraint ; i_Constraint++) {        Constraint_P =      (struct ConstraintInFS*)List_Pointer(Constraint_L, i_Constraint) ;    ConstraintPerRegion_P = Constraint_P->ConstraintPerRegion ;        if (Constraint_P->QuantityType == GLOBALQUANTITY) {      switch(ConstraintPerRegion_P->Type) {	      case ASSIGN :                case INIT :      case ASSIGNFROMRESOLUTION :  case INITFROMRESOLUTION :      case CST_LINK : case CST_LINKCPLX :	GlobalQuantity_Pr = (struct GlobalQuantity*)	  List_Pointer(FunctionSpace_P->GlobalQuantity,		       Constraint_P->ReferenceIndex) ;	if (GlobalQuantity_Pr == GlobalQuantity_P) {	  	  GroupEntity_Pr = (struct Group*)	    List_Pointer(Problem_S.Group, Constraint_P->EntityIndex) ;	  	  if (/*(GroupEntity_Pr->FunctionType == 		((struct Group *)List_Pointer(Problem_S.Group, 		BasisFunction_P->EntityIndex))		->FunctionType)  && */	      List_Search	      (GroupEntity_Pr->InitialList,	       &QuantityStorage_P->BasisFunction[0].CodeEntity, fcmp_int) ) {	    QuantityStorage_P->BasisFunction[0].Constraint =	      ConstraintPerRegion_P->Type ;	    if (ConstraintPerRegion_P->Type == ASSIGN ||		ConstraintPerRegion_P->Type == INIT)	      Get_ValueForConstraint		(Constraint_P, QuantityStorage_P->BasisFunction[0].Value,		 &QuantityStorage_P->BasisFunction[0].TimeFunctionIndex) ;	    else if (ConstraintPerRegion_P->Type == CST_LINK ||		     ConstraintPerRegion_P->Type == CST_LINKCPLX) {	      Get_LinkForConstraint		(Constraint_P,		 QuantityStorage_P->BasisFunction[0].CodeEntity,		 &QuantityStorage_P->BasisFunction[0].CodeEntity_Link,		 QuantityStorage_P->BasisFunction[0].Value) ;	      if (QuantityStorage_P->BasisFunction[0].CodeEntity ==		  QuantityStorage_P->BasisFunction[0].CodeEntity_Link)		  QuantityStorage_P->BasisFunction[0].Constraint = NONE ;		/* Code linked with itself not allowed */	    }	    else	      Get_PreResolutionForConstraint		(Constraint_P,		 &QuantityStorage_P->BasisFunction[0].TimeFunctionIndex) ;	  }	}	break ;  /* ASSIGN || INIT || ASSIGNFROMRESOLUTION || INITFROMRESOLUTION */      default :	Msg(GERROR, "Unknown type of Constraint");	break;      }    }  /* if (GLOBALQUANTITY) ... */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -