Exemplo n.º 1
0
/* generate database file name for the given ID */
void ExodusOutputT::FileName(int ID, StringT& filename) const
{
	/* root */
	filename = fOutroot;

	/* tack on sequence number */
	if (fSequence > 0) filename.Append(".sq", fSequence + 1);

	/* group number */
	//filename.Append(".gp", fElementSets[ID]->ID());
	//NOTE: it's hard to resolve the number of element groups from the
	//      number of io groups based solely on what's in the database,
	//      so skip it for now.	

	/* I/O ID */
	filename.Append(".io", ID);

	/* changing geometry */
	if (fElementSets[ID]->Changing())
		filename.Append(".ps", fElementSets[ID]->PrintStep(), 4);
			/* assuming no more than 1000 output steps */

	/* extension */
	filename.Append(".exo");
}
Exemplo n.º 2
0
StringT ParaDynOutputT::CreateFileName (const StringT& Label) const
{
  StringT var (fOutroot);
  
  /* tack on extension */
  var.Append (".");
  var.Append (Label);
  return var;
}
Exemplo n.º 3
0
/* collect global and local iterations info for each time step */
void MRSSKStV::GetIterationInfo(bool get_iters, int loc_iters)
{
	if(get_iters) {
		
		/* write data */
		const StringT& input_file = fSSMatSupport->InputFile();
	
		/* output filenames */
		StringT iterdata;
		iterdata.Root(input_file);
	
		iterdata.Append(".iterdata.", fSSMatSupport->StepNumber());
		
		/* open output streams */
		ofstreamT out_idata(iterdata);

		/* write */
		out_idata << "Time step number:       " << setw(kIntWidth) 
		          << fSSMatSupport->StepNumber() << endl;
		out_idata << "Global iteration number:" << setw(kIntWidth) 
		          << fSSMatSupport->GroupIterationNumber() << endl;
		out_idata << "Number of local iterations to converge:" << setw(kIntWidth) 
		          << loc_iters << endl;
		out_idata.close(); /* close */
		
	} // if(get_iters)
}
Exemplo n.º 4
0
void NodeManagerPrimitive::RegisterOutput (OutputBaseT& output, MakeCSE_IOManager& input)
{
  // FUTURE: carry over node tags
  fOutputNodeMap.Dimension (fCoordinates.MajorDim());
  fOutputNodeMap.SetValueToPosition ();
  fOutputNodeMap ++;

  output.SetCoordinates (fCoordinates, &fOutputNodeMap);

  sArrayT blocktonodesets;
  input.BlockToNode (blocktonodesets);

  int nsetid = 1;
  
  for (int g=0; g < fNodeSetID.Length(); g++)
    if  (nsetid < atoi (fNodeSetID[g])) 
      nsetid = atoi (fNodeSetID[g]) + 1;

  iArrayT nodes;
  for (int i=0; i < blocktonodesets.Length(); i++)
    {
      StringT name;
      name.Append (nsetid + 1);
      out  << "\n Creating Node Set from Element Group ID . . . . = "
	   << blocktonodesets[i] << '\n';
      theBoss->NodesUsed (blocktonodesets[i], nodes);
      if (nodes.Length() > 0)
	AddNodeSet (name, nodes, CSEConstants::kSplit);
      else
	out << "\n     No nodes found...\n";
    }

  for (int n=0; n < fNodeSetData.Length(); n++)
    output.AddNodeSet (fNodeSetData[n], fNodeSetID[n]);
}
Exemplo n.º 5
0
void ExtractIOManager::OpenFile (ofstreamT& o, const StringT& name, bool append) const
{
  StringT filename (fOutputName);
  filename.Append ("_");
  for (int i=name.StringLength(); i < fNumDigits; i++)
    filename.Append ("0");
  filename.Append (name);
  filename.Append (".", fOutfileExtension);
  if (!append)
    {
      remove (filename); // remove any pre-existing file
      o.open (filename);
    }
  else
    o.open_append (filename);
  if (!o.is_open())
    ExceptionT::GeneralFail ("ExtractIOManager::OpenFile","Unable to open %s", filename.Pointer());
}
Exemplo n.º 6
0
void DiagonalMatrixT::PrintLHS(bool force) const
{
	if (!force && fCheckCode != GlobalMatrixT::kPrintLHS) return;

	/* output stream */
	StringT file = fstreamT::Root();
	file.Append("DiagonalMatrixT.LHS.", sOutputCount);
	if (fComm.Size() > 1) file.Append(".p", fComm.Rank());		
	ofstreamT out(file);
	out.precision(14);

	/* write non-zero values in RCV format */
	for (int i = 0; i < fLocNumEQ; i++)
		out << i+1 << " " << i+1 << " " << fMatrix[i] << '\n';	

	/* increment count */
	sOutputCount++;
}
Exemplo n.º 7
0
bool TextInputT::OpenFile (ifstreamT& in, const char* ext) const
{
  StringT file (fFileRoot);
  file.Append (ext);
  in.open (file);
  if (!in.is_open()) 
    {
      fout << "\nTextInputT::OpenFile unable to open " << file << "\n\n";
      return false;
    }
  return true;
}
Exemplo n.º 8
0
/* describe the parameters needed by the interface */
void MatrixParameterT::DefineParameters(ParameterListT& list) const
{
	/* inherited */
	ParameterInterfaceT::DefineParameters(list);

	/* add flag */
	ParameterT copy_symmmetric(fCopySymmetric, "copy_symmetric");
	copy_symmmetric.SetDefault(fCopySymmetric);
	list.AddParameter(copy_symmmetric);

	/* define components */
	for (int i = 0; i < fMatrix.Cols(); i++)
		for (int j = 0; j < fMatrix.Rows(); j++) {
			StringT A = "A_";
			A[0] = fVariable;
			A.Append(j+1);
			A.Append("_", i+1);
			ParameterT A_ji(ParameterT::Double, A);
			A_ji.SetDefault(0.0);
			list.AddParameter(A_ji);
		}
}
Exemplo n.º 9
0
/* describe the parameters needed by the interface */
void VectorParameterT::DefineParameters(ParameterListT& list) const
{
	/* inherited */
	ParameterInterfaceT::DefineParameters(list);

	/* define components */
	for (int i = 0; i < fVector.Length(); i++) {
		StringT v = "v_";
		v[0] = fVariable;
		v.Append(i+1);
		ParameterT v_i(ParameterT::Double, v);
		v_i.SetDefault(0.0);
		list.AddParameter(v_i);
	}
}
Exemplo n.º 10
0
/* accept parameter list */
void CSEBaseT::TakeParameterList(const ParameterListT& list)
{
	const char caller[] = "CSEBaseT::TakeParameterList";

	/* axisymmetry */
	fAxisymmetric = list.GetParameter("axisymmetric");
	if (fAxisymmetric && NumSD() != 2) /* check */
		ExceptionT::GeneralFail(caller, "expecting 2 dimensions not %d with axisymmetry", NumSD());

	/* element geometry - need to set geometry before calling inherited method */
	const ParameterListT& geom = list.GetListChoice(*this, "surface_geometry");
	fGeometryCode = GeometryT::string2CodeT(geom.Name());
	fNumIntPts = geom.GetParameter("num_ip");

	/* inherited */
	ElementBaseT::TakeParameterList(list);

	/* take parameters */
	fCloseSurfaces = list.GetParameter("close_surfaces");
	fOutputArea = list.GetParameter("output_area");

	/* pre-crack */
	const ParameterListT* pre_crack = list.List("pre_crack");
	if (pre_crack) {
		fpc_AndOr = int2AndOrT(pre_crack->GetParameter("and_or"));
		int num_rules = pre_crack->NumLists("pre_crack_rule");
		fpc_coordinate.Dimension(num_rules);
		fpc_op.Dimension(num_rules);
		fpc_value.Dimension(num_rules);
		for (int i = 0; i < num_rules; i++) {
			const ParameterListT& pre_crack_rule = pre_crack->GetList("pre_crack_rule", i);
			fpc_coordinate[i] = int2CoordinateT(pre_crack_rule.GetParameter("coordinate"));
			fpc_op[i] = int2OpT(pre_crack_rule.GetParameter("op"));
			fpc_value[i] = pre_crack_rule.GetParameter("value");
		}
	}

	/* nodal output codes */
	fNodalOutputCodes.Dimension(NumNodalOutputCodes);
	fNodalOutputCodes = 0;
	const ParameterListT* nodal_output = list.List("surface_element_nodal_output");
	if (nodal_output)
		for (int i = 0; i < NumNodalOutputCodes; i++)
		{
			/* look for entry */
			const ParameterT* nodal_value = nodal_output->Parameter(NodalOutputNames[i]);
			if (nodal_value) {
				int do_write = *nodal_value;
				if (do_write == 1)
					fNodalOutputCodes[i] = 1;
				else if (i == NodalTraction && do_write == 2) {
					fNodalOutputCodes[i] = 1;
					fOutputGlobalTractions = true;
				}
			}
		}

	/* element output codes */
	fElementOutputCodes.Dimension(NumElementOutputCodes);
	fElementOutputCodes = 0;
	const ParameterListT* element_output = list.List("surface_element_element_output");
	if (element_output)
		for (int i = 0; i < NumElementOutputCodes; i++)
		{
			/* look for entry */
			const ParameterT* element_value = element_output->Parameter(ElementOutputNames[i]);
			if (element_value) {
				int do_write = *element_value;
				if (do_write == 1)
					fElementOutputCodes[i] = 1;
			}
		}

	/* dimensions */
	int num_facet_nodes = NumFacetNodes();

	/* initialize local arrays */
	fLocInitCoords1.Dimension(num_facet_nodes, NumSD());
	fLocCurrCoords.Dimension(NumElementNodes(), NumSD());
	ElementSupport().RegisterCoordinates(fLocInitCoords1);
	ElementSupport().RegisterCoordinates(fLocCurrCoords);

	/* construct surface shape functions */
	fShapes = new SurfaceShapeT(fGeometryCode, fNumIntPts, NumElementNodes(), 
		num_facet_nodes, NumDOF(), fLocInitCoords1);
	if (!fShapes) throw ExceptionT::kOutOfMemory;
	fShapes->Initialize();

	/* work space */
	fNodes1.Dimension(num_facet_nodes);
	int nee = NumElementNodes()*NumDOF();
	fNEEvec.Dimension(nee);
	fNEEmat.Dimension(nee);

	/* close surfaces */
	if (fCloseSurfaces) CloseSurfaces();

#ifndef _FRACTURE_INTERFACE_LIBRARY_
	/* output stream */
	if (fOutputArea == 1)
	{
		/* generate file name */
		StringT name = ElementSupport().InputFile();
		name.Root();
		name.Append(".grp", ElementSupport().ElementGroupNumber(this) + 1);
		name.Append(".fracture");
		
		/* open stream */
		farea_out.open(name);
	}
#endif
}
Exemplo n.º 11
0
/* echo contact bodies and striker nodes. After the read section, should have valid 
 * nodes/facet connectivities for the local database. */
void MFPenaltyContact2DT::ExtractContactGeometry(const ParameterListT& list)
{
	const char caller[] = "ContactT::ExtractContactGeometry";

	/* output stream */
	ofstreamT& out = ElementSupport().Output();
	bool print_input = ElementSupport().PrintInput();

	/* get surfaces */
	int num_surfaces = list.NumLists("contact_surface");
	fSurfaces.Dimension(num_surfaces);

	/* read contact bodies */
	for (int i = 0; i < fSurfaces.Length(); i++)
	{
		const ParameterListT& surface_spec = list.GetListChoice(*this, "contact_surface", i);

		if (surface_spec.Name() == "surface_side_set")
			InputSideSets(surface_spec, fSurfaces[i]);
		else if (surface_spec.Name() == "body_boundary") 
		{
			/* may resize the surfaces array */
			InputBodyBoundary(surface_spec, fSurfaces, i);
			num_surfaces = fSurfaces.Length();
		}
		else
			ExceptionT::GeneralFail(caller, "unrecognized contact surface \"%s\"",
				surface_spec.Name().Pointer());
	}
	
	/* echo data  */
	out << " Contact surfaces:\n";
	out << setw(kIntWidth) << "surface"
	    << setw(kIntWidth) << "facets"
	    << setw(kIntWidth) << "size" << '\n';
	for (int j = 0; j < fSurfaces.Length(); j++)
	{		
	  	iArray2DT& surface = fSurfaces[j];

	  	out << setw(kIntWidth) << j+1
	  	    << setw(kIntWidth) << surface.MajorDim()
	  	    << setw(kIntWidth) << surface.MinorDim() << "\n\n";
  	
		/* verbose */
		if (print_input) {
			surface++;
			surface.WriteNumbered(out);
			surface--;
			out << '\n';
	  	}
	}

	/* look for empty surfaces */
	int surface_count = 0;	
	for (int j = 0; j < fSurfaces.Length(); j++)
		if (fSurfaces[j].MajorDim() > 0)
			surface_count++;

	/* remove empty surfaces */
	if (surface_count != fSurfaces.Length())
	{
		out << " Found empty contact surfaces:\n\n";
		ArrayT<iArray2DT> tmp_surfaces(surface_count);
		surface_count = 0;
		for (int i = 0; i < fSurfaces.Length(); i++)
		{
	  		iArray2DT& surface = fSurfaces[i];
			if (surface.MajorDim() == 0)
				out << " removing surface " << i+1 << '\n';
			else
				tmp_surfaces[surface_count++].Swap(surface);
		}
		
		/* exchange */
		fSurfaces.Swap(tmp_surfaces);
	}

	/* get strikers */
	const ParameterListT& striker_spec = list.GetListChoice(*this, "contact_nodes");
	if (striker_spec.Name() == "node_ID_list")
		StrikersFromNodeSets(striker_spec);
	else if (striker_spec.Name() == "side_set_ID_list")
		StrikersFromSideSets(striker_spec);
	else if (striker_spec.Name() == "all_surface_nodes")
		StrikersFromSurfaces();
	else if (striker_spec.Name() == "all_nodes_as_strikers")
	{
		//TEMP
		if (fSCNI) ExceptionT::GeneralFail(caller, "\"all_nodes_as_strikers\" not supported with SCNI");
		fStrikerTags.Alias(fMeshFreeSupport->NodesUsed());
	}
	else
		ExceptionT::GeneralFail(caller, "unrecognized contact node specification \"\"",
			striker_spec.Name().Pointer());

	/* check to see that all strikers are meshfree - only apply check with meshless methods
	 * using fMeshFreeSupport. The SCNI classes do this check later. */
	if (striker_spec.Name() != "all_nodes_as_strikers" && fMeshFreeSupport) {
		InverseMapT map;
		map.SetOutOfRange(InverseMapT::MinusOne);
		map.SetMap(fMeshFreeSupport->NodesUsed());
		for (int i = 0; i < fStrikerTags.Length(); i++)
			if (map.Map(fStrikerTags[i]) == -1)
				ExceptionT::GeneralFail(caller, "striker %d is not meshfree", fStrikerTags[i]+1);
	}

	/* echo */
	if (print_input) {
		out << "\n Striker nodes:\n";
		fStrikerTags++;
		out << fStrikerTags.wrap(8) << '\n';
		fStrikerTags--;	
	}

	/* collect SCNI data for all striker tags */
	if (fSCNI)
	{
		/* set map of node ID to meshfree point index */
		fNodeToMeshFreePoint.SetMap(fStrikerTags);

		/* map global ID to local numbering */
		fSCNI_LocalID = fStrikerTags;
		if (!fSCNI->GlobalToLocalNumbering(fSCNI_LocalID))
			ExceptionT::GeneralFail(caller, "SCNI global->local failed");
	
		/* collect nodal neighbors and shape functions */
		fSCNI->NodalSupportAndPhi(fSCNI_LocalID, fSCNI_Support, fSCNI_Phi);
	}

	/* set connectivity name */
	ModelManagerT& model = ElementSupport().ModelManager();
	StringT name ("Contact");
	name.Append (ElementSupport().ElementGroupNumber(this) + 1);

	/* register with the model manager and let it set the ward */
	int nen = fNumFacetNodes + 1; /* facet nodes + 1 striker */
	if (!model.RegisterElementGroup(name, GeometryT::kLine, nen)) 
		ExceptionT::GeneralFail(caller, "could not register contact facets");

	/* set up fConnectivities */
	fConnectivities.Dimension(1);
	fConnectivities[0] = model.ElementGroupPointer(name);

	/* set up fBlockData to store block ID */
	fBlockData.Dimension(1);
	fBlockData[0].Set(name, 0, fConnectivities[0]->MajorDim(), -1);

	/* set managed equation numbers array */
	fEqnos.Dimension(1);
	fEqnos_man.SetWard(0, fEqnos[0], nen*NumDOF());
}
Exemplo n.º 12
0
void ExodusOutputT::CreateGeometryFile(ExodusT& exo)
{
  /* create integer ID values from string values */
  String2IntIDs (fNodeSetNames, fNodeSetIntIDs);
  String2IntIDs (fSideSetNames, fSideSetIntIDs);

  StringT filename = fOutroot;

  /* changing geometry */
  bool change = false;
  for (int j=0; j < fElementSets.Length() && !change; j++)
    if (fElementSets[j]->Changing()) change = true;
  if (change)
    filename.Append(".ps", fElementSets[0]->PrintStep());
  filename.Append(".exo");
  
  int dim = fCoordinates->MinorDim();
  int num_nodes = fCoordinates->MajorDim();
  int num_node_sets = fNodeSets.Length();
  int num_side_sets = fSideSets.Length();
  
  int num_elem = 0, num_blks = 0;
  for (int e=0; e < fElementSets.Length(); e++)
      {
	num_blks += fElementSets[e]->NumBlocks();
	num_elem += fElementSets[e]->NumElements();
      }
  
  ArrayT<StringT> info, qa;
  AssembleQA (qa);
  exo.Create (filename, fTitle, info, qa, dim, num_nodes,
	      num_elem, num_blks, num_node_sets, num_side_sets);
  
  // write coordinates
  iArrayT nodes_used (num_nodes);
  nodes_used.SetValueToPosition();
  WriteCoordinates (exo, nodes_used);
  
  // write connectivities
  for (int i=0; i < fElementSets.Length(); i++)
      WriteConnectivity (i, exo, nodes_used);
  
  // write node sets
  for (int n=0; n < fNodeSets.Length(); n++)
    {
      iArrayT& set = *((iArrayT*) fNodeSets[n]);
      set++;
      // exodus does not support string labels, use index instead
      exo.WriteNodeSet (fNodeSetIntIDs[n], set);
      set--;
    }
  
  // write side sets, send local element numbering
  // send element block ID, not group index
  for (int s=0; s < fSideSets.Length(); s++)
    {
      /* search for group name */
      StringT& gname = fSSGroupNames [s];
      int gindex, bindex;
      ElementGroupBlockIndex (gname, gindex, bindex);

      int block_ID = fElementBlockIDs[gindex][bindex];
      iArray2DT& set = *((iArray2DT*) fSideSets[s]);
      set++;
      // exodus does not support string labels, use index instead
      exo.WriteSideSet (fSideSetIntIDs[s], block_ID, set);
      set--;
    }
}
Exemplo n.º 13
0
void ContactElementT::WriteOutput(void)
{
ExceptionT::GeneralFail("ContactElementT::WriteOutput", "out of date");
#if 0
// look at EXODUS output in continuumelementT
	/* contact statistics */
	ostream& out = ElementSupport().Output();
	out << "\n Contact tracking: group "
                << ElementSupport().ElementGroupNumber(this) + 1 << '\n';
	out << " Time                           = "
                << ElementSupport().Time() << '\n';
	if (fNumOutputVariables) {
		for(int s = 0; s < fSurfaces.Length(); s++) {
			const ContactSurfaceT& surface = fSurfaces[s];
			dArray2DT n_values(surface.GlobalNodeNumbers().Length(), 
							fNumOutputVariables);
			n_values = 0.0;
			surface.CollectOutput(fOutputFlags,n_values);
			dArray2DT e_values;
			/* send to output */
			ElementSupport().WriteOutput(fOutputID[s], n_values, e_values);
		}
	}

	/* output files */
	StringT filename;
	filename.Root(ElementSupport().Input().filename());
	filename.Append(".", ElementSupport().StepNumber());
	filename.Append("of", ElementSupport().NumberOfSteps());

	for(int s = 0; s < fSurfaces.Length(); s++) {
		const ContactSurfaceT& surface = fSurfaces[s];

#if TEXT_OUTPUT
		if (fOutputFlags[kGaps]) {
                StringT gap_out;
                gap_out = gap_out.Append(filename,".gap");
                gap_out = gap_out.Append(s);
                ofstream gap_file (gap_out);
                surface.PrintGaps(gap_file);


		}
		if (fOutputFlags[kMultipliers]) {
//		surface.PrintMultipliers(cout);
                StringT pressure_out;
                pressure_out = pressure_out.Append(filename,".pre");
                pressure_out = pressure_out.Append(s);
                ofstream pressure_file (pressure_out);
                surface.PrintMultipliers(pressure_file);
		}

		if (fOutputFlags[kNormals]) {
                StringT normal_out;
                normal_out = normal_out.Append(filename,".normal");
                normal_out = normal_out.Append(s);
                ofstream normal_file (normal_out);
                surface.PrintNormals(normal_file);
		}
#endif

		if (fOutputFlags[kMultipliers]) { surface.PrintMultipliers(cout);}
		if (fOutputFlags[kStatus]) { surface.PrintStatus(cout); }
		if (fOutputFlags[kArea]) { surface.PrintContactArea(cout); }
	}
#endif
}