示例#1
0
// Set flags for this material being rigid and for if it ignores cracks
// Not that ignoring cracks only works for multimaterial mode. Rigid contact
//    materials default to ignoring cracks while non rigid default to see them
int MaterialBase::GetMVFFlags(int matfld)
{	// check number errors
	if(matfld>=(int)fieldMatIDs.size()) return 0;
	
	MaterialBase *matID = theMaterials[fieldMatIDs[matfld]];
	int flags = matID->Rigid() ? RIGID_FIELD_BIT : 0 ;
	return flags;
}
示例#2
0
// Adjust time step now
CustomTask *CarnotCycle::StepCalculation(void)
{
    
    int p;
	MaterialBase *matID;
	
	double Vrel = 0.;
	int numgas = 0;
	double Tgas = 0.;
    
    // loop over nonrigid material points
    for(p=0;p<nmpmsNR;p++)
	{	numgas++;
		Vrel += mpm[p]->GetRelativeVolume();
		Tgas += mpm[p]->pPreviousTemperature;
	}
	
	// get averages
	Vrel /= (double)numgas;
	Tgas /= (double)numgas;
	
	switch(carnotStep)
	{	case 0:
			carnotStep = 1;
			cout << "# Step 1: isothermal expansion" << endl;
            ConductionTask::adiabatic = FALSE;
			break;
			
		case 1:
			// stop when Vrel reaches V1rel
			if(Vrel >= V1rel)
			{	// switch to adibatic expanion
				carnotStep = 2;
				ConductionTask::adiabatic = TRUE;
				cout << "# Step 2: adibatic expansion" << endl;
			}
			break;
		
		case 2:
			// stop when T cools to T2
			if(Tgas<=T2)
			{	// switch to pause
				carnotStep = 3;
				ConductionTask::adiabatic = FALSE;
				V2rel = Vrel;
				
				// find velocity
				for(p=0;p<nmpms;p++)
				{	// verify material is defined and sets if field number (in in multimaterial mode)
					matID=theMaterials[mpm[p]->MatID()];	// material object for this particle
					if(matID->Rigid())
						mpm[p]->ReverseParticle(false,false);
					else
						mpm[p]->StopParticle();
				}
				
				// estimate next volume
				if(V3rel<1.)
					V3rel = V2rel/V1rel;
				
				cout << "# Step 2: isothermal compression to " << V3rel << "*V0" << endl;
			}
			break;
		
		case 3:
			// stop when Vrel reaches V3rel
			if(Vrel <= V3rel)
			{	// switch to adibatic compression
				carnotStep = 4;
				ConductionTask::adiabatic = TRUE;
				cout << "# Step 4: adibatic compression" << endl;
			}
			break;
		
		case 4:
			// done when T increases to thermal.reference, or when volume returns to 1
			if(Tgas>=thermal.reference)
				throw CommonException("Carnot cycle is complete","CarnotCycle::StepCalculation()");
			//if(Vrel<=1.)
			//	throw CommonException("Carnot cycle is complete","CarnotCycle::StepCalculation()");
			break;
		
		default:
			break;
	}

    return nextTask;
}
示例#3
0
// when set, return total number of materials if this is a new one, or 1 if not in multimaterial mode
// not thread safe due to push_back()
int MaterialBase::SetField(int fieldNum,bool multiMaterials,int matid,int &activeNum)
{	if(!multiMaterials)
	{	if(field<0)
		{	field=0;
			activeField=activeNum;
			fieldNum=1;
			activeNum++;
			activeMatIDs.push_back(matid);
            int altBuffer,matBuffer = SizeOfMechanicalProperties(altBuffer);
            if(matBuffer > maxPropertyBufferSize) maxPropertyBufferSize = matBuffer;
            if(altBuffer > maxAltBufferSize) maxAltBufferSize = altBuffer;
		}
	}
	else
	{	if(field<0)
		{	// if sharing a field, look up shared material.
			if(shareMatField>0)
			{	if(shareMatField>nmat)
				{	throw CommonException("Material class trying to share velocity field with an undefined material type",
										  "MaterialBase::SetField");
				}
			
				// must match for rigid feature
				MaterialBase *matRef = theMaterials[shareMatField-1];
				if(matRef->Rigid() != Rigid())
				{	throw CommonException("Material class trying to share velocity field with an incompatible material type",
										  "MaterialBase::SetField");
				}
			
				// base material cannot share too
				if(matRef->GetShareMatField()>=0)
				{	throw CommonException("Material class trying to share velocity field with a material that share's its field",
										  "MaterialBase::SetField");
				}

				// set field to other material (and set other material if needed
				field = matRef->GetField();
				if(field<0)
				{	fieldNum = matRef->SetField(fieldNum,multiMaterials,shareMatField-1,activeNum);
					field = fieldNum-1;
				}
			}
			else
			{	field=fieldNum;
				fieldNum++;
				
				// fieldMatIDs[i] for i=0 to # materials is material index for that material velocity field
				// when materials share fields, it points to the based shared material
				fieldMatIDs.push_back(matid);
			}
			
			// for first particle using this material, add to active material IDs and check required
			// material buffer sizes
			if(activeNum>=0)
			{	activeField=activeNum;
				activeNum++;
				activeMatIDs.push_back(matid);
                int altBuffer,matBuffer = SizeOfMechanicalProperties(altBuffer);
                if(matBuffer > maxPropertyBufferSize) maxPropertyBufferSize = matBuffer;
                if(altBuffer > maxAltBufferSize) maxAltBufferSize = altBuffer;
			}
		}
	}
	return fieldNum;
}