Ejemplo n.º 1
0
void _SnacViscoPlastic_CheckpointPlasticStrain( void* _context ) {
	Snac_Context*				context = (Snac_Context*) _context;
	SnacViscoPlastic_Context*	contextExt = ExtensionManager_Get(
												context->extensionMgr,
												context,
												SnacViscoPlastic_ContextHandle );
	Element_LocalIndex			element_lI;

#if DEBUG
	printf( "In %s()\n", __func__ );
#endif
	
	for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
		Snac_Element* 				element = Snac_Element_At( context, element_lI );
		SnacViscoPlastic_Element*	elementExt = ExtensionManager_Get(
													context->mesh->elementExtensionMgr,
													element,
													SnacViscoPlastic_ElementHandle );
		Tetrahedra_Index	tetra_I;
		for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
			float plasticStrain = elementExt->plasticStrain[tetra_I];
			fwrite( &plasticStrain, sizeof(float), 1, contextExt->plStrainCheckpoint );
		}
		fflush( contextExt->plStrainCheckpoint );
	}
}
Ejemplo n.º 2
0
void _SnacViscoPlastic_CheckpointViscosity( void* _context ) {
	Snac_Context*				context = (Snac_Context*) _context;
	SnacViscoPlastic_Context*	contextExt = ExtensionManager_Get(
												context->extensionMgr,
												context,
												SnacViscoPlastic_ContextHandle );
	Element_LocalIndex			element_lI;
	
#if DEBUG
	printf( "In %s()\n", __func__ );
#endif
	
	for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
		Snac_Element* 					element = Snac_Element_At( context, element_lI );
		SnacViscoPlastic_Element*		elementExt = ExtensionManager_Get(
														context->mesh->elementExtensionMgr,
														element,
														SnacViscoPlastic_ElementHandle );
		Tetrahedra_Index		tetra_I;
		double					viscosity = 0.0f;
		float					logviscosity = 0.0f;

		for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
			viscosity = elementExt->viscosity[tetra_I];
			assert(viscosity>0.0);
			logviscosity = log10(viscosity);
			fwrite( &logviscosity, sizeof(float), 1, contextExt->viscCheckpoint );
		}
	}
	fflush( contextExt->viscCheckpoint );
}
Ejemplo n.º 3
0
void interpolateNode( void* _context, Node_LocalIndex newNodeInd, Element_DomainIndex dEltInd ) {
	Snac_Context*			context = (Snac_Context*)_context;
	SnacRemesher_Context*	contextExt = ExtensionManager_Get( context->extensionMgr,
															   context,
															   SnacRemesher_ContextHandle );
	Mesh*					mesh = context->mesh;
	SnacRemesher_Mesh*		meshExt = ExtensionManager_Get( context->meshExtensionMgr,
															mesh,
															SnacRemesher_MeshHandle );
	NodeLayout*				nLayout = mesh->layout->nodeLayout;
	unsigned				nEltNodes;
	Node_DomainIndex*		eltNodes;
	Coord					newNodeCoord;
	Coord					crds[8];
	double					weights[4];
	unsigned				tetNodeInds[4];
	unsigned				eltNode_i;

	/* Extract the element's node indices.  Note that there should always be eight of these. */
	{
		Element_GlobalIndex	gEltInd;

		nEltNodes = 8;
		eltNodes = Memory_Alloc_Array( Node_DomainIndex, nEltNodes, "SnacRemesher" );
		gEltInd = Mesh_ElementMapDomainToGlobal( mesh, dEltInd );
		nLayout->buildElementNodes( nLayout, gEltInd, eltNodes );
	}

	/* Convert global node indices to domain. */
	{
		unsigned	eltNode_i;

		for( eltNode_i = 0; eltNode_i < nEltNodes; eltNode_i++ ) {
			eltNodes[eltNode_i] = Mesh_NodeMapGlobalToDomain( mesh, eltNodes[eltNode_i] );
		}
	}

	/* Extract the new node's coordinate. */
	Vector_Set( newNodeCoord, meshExt->newNodeCoords[newNodeInd] );

	/* Copy coordinates. */
	for( eltNode_i = 0; eltNode_i < nEltNodes; eltNode_i++ )
		memcpy( crds[eltNode_i], mesh->nodeCoord[eltNodes[eltNode_i]], sizeof(Coord) );

	if( !_HexaEL_FindTetBarycenter( crds, newNodeCoord, weights, tetNodeInds, INCLUSIVE_UPPER_BOUNDARY, NULL, 0 ) )
		abort();

	SnacRemesher_InterpolateNode( context, contextExt,
				      newNodeInd, dEltInd, 0,
				      tetNodeInds, weights,
				      meshExt->newNodes );

	/* Free the element node array. */
	FreeArray( eltNodes );
}
void _ParticleMelting_Initialise( void* _self, void* data ) {
	ParticleMelting* self = (ParticleMelting*) _self;
   unsigned par_i, lpartCount;
   MaterialPoint *particle;
   ParticleMelting_ParExt *parExt;

	Stg_Component_Initialise( self->temperatureField, data, False );
	Stg_Component_Initialise( self->materialSwarm, data, False );
	if( self->pressureField )
	  Stg_Component_Initialise( self->pressureField, data, False );
	if( self->scaling )
	  Stg_Component_Initialise( self->scaling, data, False );

	
	if( !self->context->loadFromCheckPoint ) {

	  lpartCount = self->materialSwarm->particleLocalCount;
	  
	  for( par_i = 0 ; par_i < lpartCount ; par_i++  ) {
		 particle = (MaterialPoint*)Swarm_ParticleAt( self->materialSwarm, par_i );
		 parExt = ExtensionManager_Get( self->materialSwarm->particleExtensionMgr, particle, self->particleExtHandle );
		 
		 /* initialise all */
		 parExt->melt = 0;
		 parExt->F = 0;
		 parExt->prevF = 0;
		 parExt->maxTheta = 0;
	  }
	}
}
Ejemplo n.º 5
0
void _SnacDikeInjection_ConstructExtensions( void* _context, void* data ) {
	Snac_Context*				context = (Snac_Context*)_context;
	SnacDikeInjection_Context*			contextExt = ExtensionManager_Get(
																		  context->extensionMgr,
																		  context,
																		  SnacDikeInjection_ContextHandle );
#ifdef DEBUG
	printf( "In %s()\n", __func__ );
#endif
	
	/* DikeInjection variables */
	contextExt->startX = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "startX", 
								   Dictionary_Entry_Value_FromDouble( 29800.0f ) ) );
	//printf("startX is not the value %d", startX )
       contextExt->startZ = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "startZ", 
								   Dictionary_Entry_Value_FromDouble( 0.0f ) ) );
	contextExt->endX = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "endX", 
								   Dictionary_Entry_Value_FromDouble( 30200.0f ) ) );
	contextExt->endZ = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "endZ", 
								   Dictionary_Entry_Value_FromDouble( 1000.0f ) ) );
	contextExt->dikeDepth = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "dikeDepth", 
								   Dictionary_Entry_Value_FromDouble( 6000.0 ) ) );
	contextExt->dikeWidth = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "dikeWidth", 
								   Dictionary_Entry_Value_FromDouble( 720 ) ) ); /* 1.8 * dx looks appropriate. */
	contextExt->injectionRate = Dictionary_Entry_Value_AsDouble(
			Dictionary_GetDefault( context->dictionary, "injectionRate", 
								   Dictionary_Entry_Value_FromDouble( 7.9e-10 ) ) ); /* a fraction of applied plate vel. */

}
void* MaterialPointsSwarm_GetMaterialExtensionOn( void* swarm, void *matPoint, Index extHandle ) {
	MaterialPointsSwarm *self  = (MaterialPointsSwarm*)swarm;
	Material *mat;

	mat = MaterialPointsSwarm_GetMaterialOn(self, matPoint);
	return ExtensionManager_Get(mat->extensionMgr, mat, extHandle);
}
void* MaterialPointsSwarm_GetMaterialExtensionAt( void* swarm, int matPointInd, Index extHandle ) {
	MaterialPointsSwarm *self  = (MaterialPointsSwarm*)swarm;
	Material *mat;

	mat = MaterialPointsSwarm_GetMaterialAt(self, matPointInd);
	return ExtensionManager_Get(mat->extensionMgr, mat, extHandle);
}
double _Pouliquen_etal_GetYieldCriterion( 
			void*                            pouliquen_etal,
			ConstitutiveMatrix*              constitutiveMatrix,
			MaterialPointsSwarm*             materialPointsSwarm,
			Element_LocalIndex               lElement_I,
			MaterialPoint*                   materialPoint,
			Coord                            xi )
{
	Pouliquen_etal*                    self             = (Pouliquen_etal*) pouliquen_etal;

	double                            frictionalStrength;
	double                            pressure;
	Pouliquen_etal_Particle*          particleExt;
	double                            strainRateInv;
	
	particleExt = (Pouliquen_etal_Particle*)ExtensionManager_Get( materialPointsSwarm->particleExtensionMgr, materialPoint, self->particleExtHandle );

	FeVariable_InterpolateWithinElement( self->pressureField, lElement_I, xi, &pressure );
	FeVariable_InterpolateWithinElement( self->strainRateInvField, lElement_I, xi, &strainRateInv );

	particleExt->pressure      = pressure;
	particleExt->strainRateInv = strainRateInv;

	frictionalStrength = self->mu_s * pressure;
	//the following is to ensure that every particle is yielding
	//frictionalStrength = -1.0;	

	return frictionalStrength;
}
Ejemplo n.º 9
0
void UpdateAverageTemp_LoopElements( void* _context )
{

	Snac_Context*           context = (Snac_Context*)_context;
	Element_LocalIndex      element_lI;
	Tetrahedra_Index	    tetra_I;
	Index                   tetraNode_I;

	for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
		Snac_Element*		element = Snac_Element_At( context, element_lI );

		for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
			Snac_Element_Tetrahedra*		tetra = &element->tetra[tetra_I];

			tetra->avgTemp = 0.0;
			for(tetraNode_I = 0; tetraNode_I < Tetrahedra_Point_Count; tetraNode_I++ ) {
				Snac_Node* contributingNode = Snac_Element_Node_P(
					context,
					element_lI,
					TetraToNode[tetra_I][tetraNode_I] );
				SnacTemperature_Node* temperatureNodeExt = ExtensionManager_Get(
					context->mesh->nodeExtensionMgr,
					contributingNode,
					SnacTemperature_NodeHandle );

				tetra->avgTemp += temperatureNodeExt->temperature/(1.0f*Tetrahedra_Point_Count);
			}
		}
	}
}
Ejemplo n.º 10
0
void _SnacViscoPlastic_DumpPlasticStrainTensor( void* _context ) {
	Snac_Context*				context = (Snac_Context*) _context;
	SnacViscoPlastic_Context*			contextExt = ExtensionManager_Get(
							context->extensionMgr,
							context,
							SnacViscoPlastic_ContextHandle );

#if DEBUG
	printf( "In %s()\n", __func__ );
#endif


	if( context->timeStep ==0 || (context->timeStep-1) % context->dumpEvery == 0 ) {
		Element_LocalIndex			element_lI;

		for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
			Snac_Element* 				element = Snac_Element_At( context, element_lI );
			SnacViscoPlastic_Element*			elementExt = ExtensionManager_Get(
																				  context->mesh->elementExtensionMgr,
																				  element,
																				  SnacViscoPlastic_ElementHandle );
			const Snac_Material* material = &context->materialProperty[element->material_I];
			Tetrahedra_Index tetra_I;


			if( material->yieldcriterion == druckerprager ) {
				for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
					Index i,j;
					float tensor[3][3];
					for(i=0;i<3;i++)
						for(j=0;j<3;j++) {
							tensor[i][j] = elementExt->plasticstrainTensor[tetra_I][i][j];
							fwrite( &tensor[i][j], sizeof(float), 1, contextExt->plstrainTensorOut );
						}
				}
			}
			else if( material->yieldcriterion == mohrcoulomb ) {
				for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
					float tetraStrain;
					tetraStrain = elementExt->plasticStrain[tetra_I];
					fwrite( &tetraStrain, sizeof(float), 1, contextExt->plstrainTensorOut );
				}
			}
		}
		fflush( contextExt->plstrainTensorOut );
	}
}
Ejemplo n.º 11
0
void* _Mesh_GetExtension( void* mesh, const unsigned int id ) {
	Mesh* self = (Mesh*)mesh;

	assert( self );
	assert( id != -1  );

	return ExtensionManager_Get( self->info, self, id  );
}
void* MaterialPointsSwarm_GetExtensionAt( void* swarm, Index point_I, Index extHandle ) {
	MaterialPointsSwarm* self  = (MaterialPointsSwarm*)swarm;
	MaterialPoint*       point;

	point = (MaterialPoint*)Swarm_ParticleAt( self, point_I );
	return ExtensionManager_Get( self->particleExtensionMgr, point, extHandle );
	
}
void* _OneToOneMapper_GetExtensionOn( void* mapper, void* point, ExtensionInfo_Index extHandle ) {
	OneToOneMapper*		self = (OneToOneMapper*)mapper;
	MaterialPointsSwarm*	swarm;
	MaterialPoint*			materialPoint; /* Assumes that material swarm holds Material particle or derivative */

	materialPoint = OneToOneMapper_GetMaterialPoint( self, point, &swarm );

	return ExtensionManager_Get( swarm->particleExtensionMgr, materialPoint, extHandle );
}
Ejemplo n.º 14
0
void* GeneralSwarm_GetExtensionAt( void* swarm, Index point_I, Index extHandle )
{
   GeneralSwarm* self  = (GeneralSwarm*)swarm;
   GlobalParticle*       point;

   point = (GlobalParticle*)Swarm_ParticleAt( self, point_I );
   return ExtensionManager_Get( self->particleExtensionMgr, point, extHandle );

}
int ParticleMelting_Get( void* _self, MaterialPoint* mp, ParticleMeltingProps prop, double *value )
{
   ParticleMelting* self = (ParticleMelting*) _self;
   ParticleMelting_MatExt *matExt;
   ParticleMelting_ParExt *parExt;

   /* Get the material of the particle */ 
   Material *material = Materials_Register_GetByIndex( self->materialSwarm->materials_Register, mp->materialIndex );

   switch( prop ) {
      case MELT_LATENTHEAT_FUSION:
         matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle );
         *value = matExt->lhf;
         break;
      case MELT_HEATCAPACITY:
         matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle );
         *value = matExt->Cp;
         break;
      case MELT_FRACTION:
         parExt = ExtensionManager_Get( self->materialSwarm->particleExtensionMgr, mp, self->particleExtHandle );
         *value = parExt->melt;
         break;
      case MELT_DEPLETION:
         parExt = ExtensionManager_Get( self->materialSwarm->particleExtensionMgr, mp, self->particleExtHandle );
         *value = parExt->F;
         break;
      case MELT_PREVDEPLETION:
         parExt = ExtensionManager_Get( self->materialSwarm->particleExtensionMgr, mp, self->particleExtHandle );
         *value = parExt->prevF;
         break;
      case MELT_ON:
         matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle );
         *value = matExt->TurnMeltOn;
         break;
      case MELT_SOLIDUS_POLY:
         matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle );
         value = matExt->sCoeff;
         break;
      case MELT_LIQUIDUS_POLY:
         matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle );
         value = matExt->lCoeff;
         break;
      default:
         printf("Error in %s; no valid property argument passed in\n", __func__ );
         return -1;
   }
   return 0;
}
void _DruckerPrager_Init(
		DruckerPrager*                                     self,
		int                                                pressure_id,
		int                                                velocityGradients_id,
		double                                             minimumYieldStress,
		double                                             frictionCoefficient,
		double                                             frictionCoefficientAfterSoftening )
{
   MaterialPointsSwarm*      materialPointsSwarm;
	DruckerPrager_Particle*   particleExt;
	StandardParticle          materialPoint;
	Dimension_Index          dim = 0;
	
	/* Assign Pointers */
	self->frictionCoefficient = frictionCoefficient;
	self->minimumYieldStress  = minimumYieldStress;
	
	self->pressureTag         = pressure_id;
	self->velocityGradientsTag = velocityGradients_id;
   materialPointsSwarm = self->mgr->materialSwarm;
   dim = materialPointsSwarm->dim;	
    /* Strain softening of Friction - (linear weakening is assumed ) */
	/* needs a softening factor between +0 and 1 and a reference strain > 0 */
	self->frictionCoefficientAfterSoftening = frictionCoefficientAfterSoftening;

   /* get the particle extension */
   self->particleExtHandle = ExtensionManager_GetHandle( materialPointsSwarm->particleExtensionMgr, (Name)DruckerPrager_Type );

   if( self->particleExtHandle == (unsigned)-1 ) {
      /* if no particles extension add it and add Update hook */
      self->particleExtHandle = ExtensionManager_Add( materialPointsSwarm->particleExtensionMgr, (Name)DruckerPrager_Type, sizeof(DruckerPrager_Particle) );

      particleExt = (double*)ExtensionManager_Get( materialPointsSwarm->particleExtensionMgr, &materialPoint, self->particleExtHandle );
      
      /* The tensileFailure variable allows to check whether a materialPoint has failed in tensile mode or not */
      self->tensileFailure = Swarm_NewScalarVariable( materialPointsSwarm, (Name)"DruckerPragerTensileFailure", (ArithPointer) &particleExt->tensileFailure - (ArithPointer) &materialPoint, Variable_DataType_Char );
      LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->tensileFailure->variable );
      LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->tensileFailure );
	   
   } else {
      /* get references to all swarm variables */
      Name var_name = Stg_Object_AppendSuffix( materialPointsSwarm, (Name)"DruckerPragerTensileFailure"  );
      self->tensileFailure = SwarmVariable_Register_GetByName( materialPointsSwarm->swarmVariable_Register, var_name );
      Memory_Free( var_name );
	   
   }

   self->curFrictionCoef = 0.0;

}
Ejemplo n.º 17
0
void _SnacRemesher_RecoverNodes( void* _context ) {
	Snac_Context*			context = (Snac_Context*)_context;
	SnacRemesher_Context*	contextExt = ExtensionManager_Get( context->extensionMgr,
															   context,
															   SnacRemesher_ContextHandle );
	Mesh*					mesh = context->mesh;
	Node_LocalIndex			newNode_i;

	/*
	** Populate arrays for recovered fields using the SPR method.
	*/
	for( newNode_i = 0; newNode_i < mesh->nodeLocalCount; newNode_i++ )
		SnacRemesher_RecoverNode( context, contextExt, newNode_i );
}
Ejemplo n.º 18
0
void _SnacExchangerForceBC_Remesh( void* _context, void* data ) {
	Snac_Context*                   context = (Snac_Context*)_context;

	/* If criterion has passed */ {
		SnacExchangerForceBC_Mesh*	meshExt = ExtensionManager_Get( context->meshExtensionMgr, context, 
							SnacExchangerForceBC_MeshHandle );
		
		/* initialise new nodes coordinates */
		_SnacExchangerForceBC_NewCoords( context );

		/* interpolate current values onto new coordinates */
		_SnacExchangerForceBC_InterpolateNodes( context );
	}
}
Ejemplo n.º 19
0
void _SnacTemperature_CheckpointTemp( void* _context ) {
	Snac_Context*				context = (Snac_Context*) _context;
	SnacTemperature_Context*	contextExt = ExtensionManager_Get(
												context->extensionMgr,
												context,
												SnacTemperature_ContextHandle );
	Node_LocalIndex				node_lI;
	
#if DEBUG
	printf( "In %s()\n", __func__ );
#endif
	
	for( node_lI = 0; node_lI < context->mesh->nodeLocalCount; node_lI++ ) {
		Snac_Node* 				node = Snac_Node_At( context, node_lI );
		SnacTemperature_Node*	nodeExt = ExtensionManager_Get(
											context->mesh->nodeExtensionMgr,
											node,
											SnacTemperature_NodeHandle );
		float					temperature = nodeExt->temperature;
		fwrite( &temperature, sizeof(float), 1, contextExt->temperatureCheckpoint );
	}
	fflush( contextExt->temperatureCheckpoint );
}
Ejemplo n.º 20
0
void _HeatingForce_ValueAtParticle(
	void*				heatingForce, 
	IntegrationPointsSwarm*		swarm, 
	Element_LocalIndex		lElement_I, 
	IntegrationPoint*		particle,
	double*				value ) 
{
	HeatingForce*			self 		= (HeatingForce*)heatingForce;
	Material*			material;
	BuoyancyMaterial_MaterialExt*	materialExt;
	
	material = IntegrationPointsSwarm_GetMaterialOn( swarm, particle );
	materialExt = ExtensionManager_Get( material->extensionMgr, material, self->buoyancyMaterial->materialExtHandle );
	*value = materialExt->extensions[self->materialIndex];
}
void _ParticleMelting_Init( 
   ParticleMelting* self,
   Bool extractMelt,
   FeVariable* temperatureField,
   FeVariable* pressureField,
   MaterialPointsSwarm* materialSwarm,
   Scaling* scaling ) {

	ParticleMelting_ParExt *parExt = NULL;
	StandardParticle particle;

   /* extractMelt:
    * For mantle set to true, according to de Smet, 98
    * For lithosphere set to false according to Patrice Rey
    */
   self->extractMelt              = extractMelt;
   self->temperatureField         = temperatureField;
   self->pressureField            = pressureField;
   self->materialSwarm = materialSwarm;
   self->scaling = scaling;

   /* add to EP, post time step, to save the previous value of melting depletion */
	/*   EntryPoint_AppendClassHook( 
      AbstractContext_GetEntryPoint(self->context, AbstractContext_EP_UpdateClass), 
      "MeltDepletionUpdate", 
      ParticleMelting_MeltFrationUpdate, 
      self->name, 
      self );
	*/

   /*
   EntryPoint_Append
   AbstractContext_EP_UpdateClass
   */

	/* now we extend the particles with 3 doubles: F, prevF and maxTheta */	
	self->particleExtHandle = ExtensionManager_Add( self->materialSwarm->particleExtensionMgr, (Name)self->type, sizeof(ParticleMelting_ParExt) );
	parExt = ExtensionManager_Get( self->materialSwarm->particleExtensionMgr, &particle, self->particleExtHandle );

	self->meltVariable = Swarm_NewScalarVariable( self->materialSwarm, (Name)"Melt", (ArithPointer) &parExt->melt - (ArithPointer) &particle, Variable_DataType_Double );

	self->FVariable = Swarm_NewScalarVariable( self->materialSwarm, (Name)"Depletion", (ArithPointer) &parExt->F - (ArithPointer) &particle, Variable_DataType_Double );
	  
	self->prevFVariable = Swarm_NewScalarVariable( self->materialSwarm, (Name)"PrevDepletion", (ArithPointer) &parExt->prevF - (ArithPointer) &particle, Variable_DataType_Double );

	self->maxThetaVariable = Swarm_NewScalarVariable( self->materialSwarm, (Name)"MaxDegreeOfMelting", (ArithPointer) &parExt->maxTheta - (ArithPointer) &particle, Variable_DataType_Double );

}
Ejemplo n.º 22
0
/*
  Copy interpolated values stored in newElement array 
  back to the original element array. 
*/
void _SnacPlastic_CopyElement( void* 					_context, 
							   Element_LocalIndex		eltInd, 
							   Tetrahedra_Index			tetInd, 
							   SnacRemesher_Element*	srcEltArray )
{

	Snac_Context*			context = (Snac_Context*)_context;
	SnacRemesher_Element* 	srcElt = &srcEltArray[eltInd];
	Snac_Element* 			dstElt = Snac_Element_At( context, eltInd );
	SnacPlastic_Element*	dstEltExt = ExtensionManager_Get(
								context->mesh->elementExtensionMgr,
								dstElt,
								SnacPlastic_ElementHandle );

	dstEltExt->plasticStrain[tetInd] = srcElt->plasticStrain[tetInd];

}
void _StoreVisc_Init(
	StoreVisc*				self,
	MaterialPointsSwarm*	materialPointsSwarm )
{
	StandardParticle           particle;
	StoreVisc_ParticleExt*     particleExt;
		
	/* Assign Pointers */
	self->materialPointsSwarm = materialPointsSwarm;

	self->particleExtHandle = ExtensionManager_Add( materialPointsSwarm->particleExtensionMgr, (Name)self->type, sizeof( StoreVisc_ParticleExt )  );
	
	/* Add SwarmVariables for plotting */
	particleExt = (StoreVisc_ParticleExt*)ExtensionManager_Get( materialPointsSwarm->particleExtensionMgr, &particle, self->particleExtHandle );
	
	self->swarmVariable = Swarm_NewScalarVariable( materialPointsSwarm, (Name)"Viscosity", (ArithPointer) &particleExt->effVisc - (ArithPointer) &particle, Variable_DataType_Double );

}
Ejemplo n.º 24
0
void _SnacRemesher_DeleteExtensions( void* _context, void* data ) {
	Snac_Context*				context = (Snac_Context*)_context;
	Mesh*					mesh = context->mesh;
	SnacRemesher_Mesh*			meshExt = ExtensionManager_Get(
							context->meshExtensionMgr,
							mesh,
							SnacRemesher_MeshHandle );
	
	Journal_Printf( context->debug, "In: %s\n", __func__ );
	
	
	/*
	** Probably will not need to do this.
	*/
	
	if( meshExt->newNodes ) {
		ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newNodes );
	}
	
#if 0
	if( meshExt->newElements ) {
		ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newElements );
	}
#endif
	
	
	/*
	** Kill the mesh extension.
	*/
	
	KillArray( meshExt->newNodeCoords );
	KillArray( meshExt->externalNodes );
	KillArray( meshExt->externalElements );
	KillArray( meshExt->topInternToLocal );
	KillArray( meshExt->botInternToLocal );
	KillArray( meshExt->topTriToDomain );
	KillArray( meshExt->botTriToDomain );
	KillArray( meshExt->yLineLTerm );
	KillArray( meshExt->yLineUTerm );
	KillArray( meshExt->yLineNYInds );
	KillArray2D( meshExt->nYLines, meshExt->yLineYInds );
	KillArray2D( meshExt->nYLines, meshExt->yLineLocalInds );
}
Ejemplo n.º 25
0
void _SnacSpherical_applyInitialVz( Index node_dI, Variable_Index var_I, void* _context, void* result ) {
	Snac_Context*                   context = (Snac_Context*)_context;
	Mesh*                           mesh = context->mesh;
	SnacSpherical_Mesh*             meshExt = ExtensionManager_Get(
													context->meshExtensionMgr,
													mesh,
													SnacSpherical_MeshHandle );
	MeshLayout*                     layout = (MeshLayout*)mesh->layout;
	HexaMD*                         decomp = (HexaMD*)layout->decomp;

	double*                         velComponent = (double*)result;
	IJK                             ijk;
	Coord*                          coord = Snac_NodeCoord_P( context, node_dI );
	double                          r,lon,lat;
	double                          lambda = deg2rad * (meshExt->min[1]+meshExt->max[1])*0.5f;
	double                          phi = deg2rad * 90.0f;
	double                          E[3],VXL[3],VXR[3];
	Node_GlobalIndex                node_gI = _MeshDecomp_Node_LocalToGlobal1D( decomp, node_dI );
	RegularMeshUtils_Node_1DTo3D( decomp, node_gI, &ijk[0], &ijk[1], &ijk[2] );

	E[0] = sin(PI/2.0f-phi)*cos(lambda);
	E[1] = sin(PI/2.0f-phi)*sin(lambda);
	E[2] = cos(PI/2.0f-phi);

	r = sqrt((*coord)[0]*(*coord)[0] + (*coord)[1]*(*coord)[1] + (*coord)[2]*(*coord)[2]);
	lat = PI/2.0f - acos((*coord)[2] / r);

	lon = meshExt->min[1] * deg2rad; //85.0*deg2rad; //atan2((*coord)[1], (*coord)[0]);
	VXL[0] = omegaL*(E[1]*(*coord)[2] - E[2]*(*coord)[1]);
	VXL[1] = omegaL*(-1.0f * E[0]*(*coord)[2] + E[2]*(*coord)[0]);
	VXL[2] = omegaL*(E[0]*(*coord)[1] - E[1]*(*coord)[0]);

	lon = meshExt->max[1] * deg2rad; //85.0*deg2rad; //atan2((*coord)[1], (*coord)[0]);
	VXR[0] = omegaR*(E[1]*(*coord)[2] - E[2]*(*coord)[1]);
	VXR[1] = omegaR*(-1.0f * E[0]*(*coord)[2] + E[2]*(*coord)[0]);
	VXR[2] = omegaR*(E[0]*(*coord)[1] - E[1]*(*coord)[0]);

	(*velComponent) = VXL[2] + (VXR[2] - VXL[2])/(decomp->elementGlobal3DCounts[0])*ijk[0];
}
void Underworld_DensityChange_Setup( UnderworldContext* context ) {
		/* Function pulls and checks user input from the xml file */
	BuoyancyForceTerm*  bft = NULL;
	BuoyancyForceTerm_MaterialExt* materialExt = NULL;;
	Stream* stream = Journal_Register( Info_Type, (Name)"cows" );
	Name   materialName = NULL;
	int materialIndex;

	/* Get self (the plugin) */
	Underworld_DensityChange* self = (Underworld_DensityChange* )LiveComponentRegister_Get( context->CF->LCRegister, (Name)Underworld_DensityChange_Type  ); 

	/* Initialise plugin data */
	self->bftExt = NULL;
	self->swarm = NULL;
	self->material = NULL;
	self->height = 0;
	self->newDensity = 0;

	/* Need buoyancy force term, to get density infomation from bft extension + the integration swarm */
	bft = Stg_ComponentFactory_ConstructByName( context->CF, (Name)"buoyancyForceTerm", BuoyancyForceTerm, True, NULL  );

	/* Read in input from root xml dictionary */
	self->height = Dictionary_GetDouble_WithDefault( context->dictionary, (Dictionary_Entry_Key)"materialDensityChangeHeight", 0.5  );
	self->newDensity = Dictionary_GetDouble_WithDefault( context->dictionary, (Dictionary_Entry_Key)"materialDensityNewDensity", 0.3 );
	self->swarm = (IntegrationPointsSwarm* )bft->integrationSwarm;
	materialName = Dictionary_GetString( context->dictionary, (Dictionary_Entry_Key)"materialDensityToChange"  );
	self->material = Materials_Register_GetByName( self->swarm->materials_Register, materialName );

	/* check if material index exists */
	if( self->material==NULL ) {
		printf("Error\nCounld find the material with index %d\n", materialIndex ); exit(0);
	}
	materialExt = (BuoyancyForceTerm_MaterialExt*)ExtensionManager_Get( self->material->extensionMgr, self->material, bft->materialExtHandle );
	Journal_RPrintf( stream, "Will change %s's density at height %g from %g to %g\n", 
			self->material->name, self->height, materialExt->density, self->newDensity );

	self->bftExt = materialExt;
}
void _StoreVisc_ModifyConstitutiveMatrix( 
		void*                                              rheology, 
		ConstitutiveMatrix*                                constitutiveMatrix,
		MaterialPointsSwarm*                               materialPointsSwarm,
		Element_LocalIndex                                 lElement_I,
		MaterialPoint*                                     materialPoint,
		Coord                                              xi )
{
	StoreVisc*	                      self              = (StoreVisc*) rheology;
	StoreVisc_ParticleExt*            particleExt;

#if 0
	/*
	** HAXOR: Throwing this flag in here to try and prevent REP from
	** overwriting the previously calculated viscosity value. */
	if ( !constitutiveMatrix->previousSolutionExists )
	  return;
#endif
                          
	/* Get Parameters From Material Extension */
	particleExt          = (StoreVisc_ParticleExt*)ExtensionManager_Get( materialPointsSwarm->particleExtensionMgr, materialPoint, self->particleExtHandle );
	particleExt->effVisc =  ConstitutiveMatrix_GetIsotropicViscosity(constitutiveMatrix);	
}
void _RateFieldTimeIntegrator_Build( void* rateFieldTimeIntegrator, void* data ) {
   RateFieldTimeIntegrator*  self = (RateFieldTimeIntegrator*) rateFieldTimeIntegrator;
   ExtensionInfo_Index   handle;

   Stg_Component_Build( self->swarm, data, False );
   Stg_Component_Build( self->rateField, data, False );

   handle = ExtensionManager_GetHandle( self->swarm->particleExtensionMgr, (Name)self->name );

   if ( handle == (ExtensionInfo_Index) -1 ) {
      ArithPointer offset;
      handle = ExtensionManager_Add( self->swarm->particleExtensionMgr, (Name)RateFieldTimeIntegrator_Type, self->rateField->fieldComponentCount*sizeof(double)  );

      /* Adding required increment variable */
      offset = (ArithPointer ) ExtensionManager_Get( self->swarm->particleExtensionMgr, NULL, handle );

      /* Add variables for vizualization / analysis purposes */
      self->particleTimeIntegral = Swarm_NewVectorVariable( self->swarm, self->name, offset, Variable_DataType_Double, self->rateField->fieldComponentCount, "STG_AUTONAME"  );
      LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->particleTimeIntegral->variable );
      LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->particleTimeIntegral );

      /* The RateFieldTimeIntegrator class inherits from the TimeIntegrand class - this class needs a 'Variable' to
       * integrate through time. */
      self->variable = self->particleTimeIntegral->variable;
   } else
      Journal_Firewall(False, Journal_Register( Error_Type, (Name)"RateFieldTimeIntegrator"  ),
                       "\n\nError in '%s' - Extension with name %s should not already exists.\n"
                       "An error has occurred.  Please contact developers.", __func__, self->name);


   /* Build parent.  Note that this needs to go last because it assumes that a variable has been set, which only just happens above */
   /* Another example where the build/init/etc phases don't work */

   _TimeIntegrand_Build( self, data );
   Stg_Component_Build( self->particleTimeIntegral, data, False );

}
void _DruckerPrager_Extra_HasYielded(
    void*                            rheology,
    ConstitutiveMatrix*              constitutiveMatrix,
    MaterialPointsSwarm*             materialPointsSwarm,
    Element_LocalIndex               lElement_I,
    MaterialPoint*                   materialPoint,
    double                           yieldCriterion,
    double                           yieldIndicator )
{
    DruckerPrager_Extra* self = (DruckerPrager_Extra*)rheology;
    DruckerPrager_Extra_Particle*           particleExt;
    double viscosity = ConstitutiveMatrix_GetIsotropicViscosity( constitutiveMatrix );
    particleExt = (DruckerPrager_Extra_Particle*)ExtensionManager_Get( materialPointsSwarm->particleExtensionMgr, materialPoint, self->particleExtHandle );

    double beta = yieldCriterion/yieldIndicator;
    double viscosity_new = viscosity*beta;

    if (viscosity_new < self->minVisc) {
        viscosity_new = self->minVisc;
    }

    _VonMises_HasYielded(
        self, constitutiveMatrix, materialPointsSwarm, lElement_I, materialPoint,
        yieldCriterion, yieldIndicator );

    /*set the plastic and background strainrate: plasticsr = tyield/eta_new - tyield/eta_old where eta_new = eta_old*(yieldC/yieldI)*/
    particleExt->plasticStrainRate = yieldCriterion*( (1/viscosity_new) - (1/viscosity) );
    particleExt->backgroundStrainRate = yieldCriterion/viscosity;

    if( constitutiveMatrix->sle && constitutiveMatrix->sle->nlFormJacobian ) {

        constitutiveMatrix->derivs[8] += viscosity * self->curFrictionCoef / yieldIndicator;

    }

}
Ejemplo n.º 30
0
void _SnacSpherical_applyPlateVy( Index node_dI, Variable_Index var_I, void* _context, void* result ) {
	Snac_Context*			context = (Snac_Context*)_context;
	Mesh*				mesh = context->mesh;
	SnacSpherical_Mesh*		meshExt = ExtensionManager_Get(
						context->meshExtensionMgr,
						mesh,
						SnacSpherical_MeshHandle );
	MeshLayout*			layout = (MeshLayout*)mesh->layout;
	HexaMD*				decomp = (HexaMD*)layout->decomp;

	double*				velComponent = (double*)result;
	const Node_GlobalIndex		midI = (decomp->nodeGlobal3DCounts[0] + 1) / 2;
	IJK				ijk;
	Node_GlobalIndex		node_gI = _MeshDecomp_Node_LocalToGlobal1D( decomp, node_dI );
	Coord*                          coord = Snac_NodeCoord_P( context, node_dI );
	double                          lambda = deg2rad * (meshExt->min[1]+meshExt->max[1])*0.5f;
	double                          phi = deg2rad * 90.0f;
	double					omega;
	double					E[3],VX[3];

	E[0] = sin(PI/2.0f-phi)*cos(lambda);
	E[1] = sin(PI/2.0f-phi)*sin(lambda);
	E[2] = cos(PI/2.0f-phi);
	RegularMeshUtils_Node_1DTo3D( decomp, node_gI, &ijk[0], &ijk[1], &ijk[2] );

 	if(ijk[0] < (midI-1))
		omega = omegaL;
 	else
		omega = omegaR;

	VX[0] = omega*(E[1]*(*coord)[2] - E[2]*(*coord)[1]);
	VX[1] = omega*(-1.0f * E[0]*(*coord)[2] + E[2]*(*coord)[0]);
	VX[2] = omega*(E[0]*(*coord)[1] - E[1]*(*coord)[0]);

	(*velComponent) = VX[1];
}