/* 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) }
/* read initial stress from file */ void MRSSKStV::InitialStress(dSymMatrixT& Stress0) { int ip = CurrIP(); ElementCardT& element = CurrentElement(); /* read data from file */ const StringT& input_file = fSSMatSupport->InputFile(); StringT InitialStressData; InitialStressData.Root(input_file); // read element by element, ip by ip // if data is generated by a program Stress0=0.; }
/* construct extracting dimensions from the name */ MatrixParameterT::MatrixParameterT(const StringT& name_NxM, char variable): ParameterInterfaceT(name_NxM), fVariable(variable), fCopySymmetric(false) { const char caller[] = "MatrixParameterT::MatrixParameterT"; const char msg[] = "could not extract %s dimensions from \"%s\" in \"%s\""; /* resolve suffix */ StringT suffix; suffix.Suffix(name_NxM, '_'); if (suffix.StringLength() < 4) ExceptionT::GeneralFail(caller, msg, "matrix", suffix.Pointer(), name_NxM.Pointer()); /* resolve column dimensions */ StringT num; num.Suffix(suffix, 'x'); if (num.StringLength() < 2 || !isdigit(num[1])) ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer()); int col = -1; col = atoi(num.Pointer(1)); if (col < 0) ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer()); /* resolve row dimensions */ suffix.Root('x'); if (suffix.StringLength() < 2 || !isdigit(suffix[1])) ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer()); int row = -1; row = atoi(suffix.Pointer(1)); if (row < 0) ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer()); /* initialize */ fMatrix.Dimension(row, col); fMatrix = 0.0; }
/* initialization */ void SCNIMFT::TakeParameterList(const ParameterListT& list) { const char caller[] = "SCNIMFT::TakeParameterList"; /* dimension */ int nsd = NumSD(); /* get parameters needed to construct shape functions */ fMeshfreeParameters = list.ListChoice(*this, "meshfree_support_choice"); /* access to the model database */ ModelManagerT& model = ElementSupport().ModelManager(); /* extract particle ID's */ const ParameterListT& particle_ID_params = list.GetList("mf_particle_ID_list"); ArrayT<StringT> particle_ID_list; StringListT::Extract(particle_ID_params, particle_ID_list); //get nodes from ModelManagerT model.ManyNodeSets(particle_ID_list, fNodes); /** This class and its derived classes assume the list of nodes is sorted */ fNodes.SortAscending(); /* set inverse map */ fNodes_inv.SetOutOfRange(InverseMapT::MinusOne); fNodes_inv.SetMap(fNodes); // get the cell geometry parameters const ParameterListT* geometry_params = list.ListChoice(*this, "cell_geometry_choice"); if (geometry_params->Name() == "voronoi_diagram") fCellGeometry = new VoronoiDiagramT(ElementSupport(), qIsAxisymmetric); else if (geometry_params->Name() == "cell_from_mesh") fCellGeometry = new CellFromMeshT(ElementSupport(), qIsAxisymmetric); else ExceptionT::GeneralFail(caller,"Cannot get valid cell geometry from input file\n"); fCellGeometry->TakeParameterList(*geometry_params); fCellGeometry->SetNodalElements(this); /* inherited */ ElementBaseT::TakeParameterList(list); /* re-dimension "element" force and stiffness contributions */ fLHS.Dimension(nsd); /* allocate work space */ fForce_man.SetWard(0, fForce, nsd); fForce_man.SetMajorDimension(ElementSupport().NumNodes(), false); /* write parameters */ ostream& out = ElementSupport().Output(); /* shape functions */ /* only support single list of integration cells for now */ if (fElementConnectivities.Length() > 1) { ExceptionT::GeneralFail(caller,"Multiple ElementConnectivities not yet supported\n"); } /* construct shape functions */ fNodalShapes = new MeshFreeNodalShapeFunctionT(nsd, ElementSupport().InitialCoordinates(), *fElementConnectivities[0], fNodalCoordinates, *fMeshfreeParameters); if (!fNodalShapes) throw ExceptionT::kOutOfMemory; /* echo parameters */ fNodalShapes->WriteParameters(ElementSupport().Output()); /* MLS stuff */ fNodalShapes->SetSupportSize(); /* exchange nodal parameters (only Dmax for now) */ const ArrayT<int>* p_nodes_in = ElementSupport().ExternalNodes(); if (p_nodes_in) { /* skip MLS fit at external nodes */ iArrayT nodes_in; nodes_in.Alias(*p_nodes_in); fNodalShapes->SetSkipNodes(nodes_in); /* exchange */ CommManagerT& comm = ElementSupport().CommManager(); /* send all */ dArray2DT& nodal_params = fNodalShapes->NodalParameters(); /* initialize the exchange */ int id = comm.Init_AllGather(nodal_params); /* do the exchange */ comm.AllGather(id, nodal_params); /* clear the communication */ comm.Clear_AllGather(id); } /* set nodal neighborhoods */ fNodalShapes->SetNeighborData(); /* final MLS initializations */ fNodalShapes->WriteStatistics(ElementSupport().Output()); /* initialize workspace for strain smoothing */ fCellGeometry->SetNodesAndShapes(&fNodes, &fNodalCoordinates, fNodalShapes); fCellGeometry->ComputeBMatrices(nodalCellSupports, bVectorArray, fCellVolumes, fCellCentroids, circumferential_B); /* store shape functions at nodes */ int nNodes = fNodes.Length(); dArrayT nodalCoords; const RaggedArray2DT<int>& nodeSupport = fNodalShapes->NodeNeighbors(); ArrayT<int> neighbor_list; ArrayT< LinkedListT<double> > nodal_phi; ArrayT< LinkedListT<int> > nodal_supports; nodal_phi.Dimension(nNodes); nodal_supports.Dimension(nNodes); for (int i = 0; i < nNodes; i++) { int node_i = fNodes[i]; nodalCoords.Alias(nsd, fNodalCoordinates(i)); neighbor_list.Dimension(nodeSupport.MinorDim(node_i)); neighbor_list.Copy(nodeSupport(node_i)); if (!fNodalShapes->SetFieldUsing(nodalCoords, neighbor_list)) // shift = 0 or not ? ExceptionT::GeneralFail("SCNIMFT::TakeParameterList","Shape Function evaluation" "failed at node %d\n",fNodes[i]); nodal_phi[i].AppendArray(fNodalShapes->FieldAt().Length(), const_cast <double *> (fNodalShapes->FieldAt().Pointer())); nodal_supports[i].AppendArray(fNodalShapes->Neighbors().Length(), const_cast <int *> (fNodalShapes->Neighbors().Pointer())); } // move into RaggedArray2DT's // move into more efficient storage for computation fNodalPhi.Configure(nodal_phi); fNodalSupports.Configure(nodal_supports); if (nodal_supports.Length() != nodal_phi.Length()) ExceptionT::GeneralFail(caller,"nodal support indices and shape function values do not match\n"); for (int i = 0; i < nodal_supports.Length(); i++) { int* irow_i = fNodalSupports(i); double* drow_i = fNodalPhi(i); LinkedListT<int>& ilist = nodal_supports[i]; LinkedListT<double>& dlist = nodal_phi[i]; ilist.Top(); dlist.Top(); while (ilist.Next() && dlist.Next()) { *irow_i++ = *(ilist.CurrentValue()); *drow_i++ = *(dlist.CurrentValue()); } } /* output nodal shape function information */ if (ElementSupport().Logging() == GlobalT::kVerbose) { /* output file root */ StringT root; root.Root(ElementSupport().InputFile()); ofstreamT out; /* nodal neighbors */ StringT neighbor_file = root; neighbor_file.Append(".", Name(), ".nodal_neighbors"); out.open(neighbor_file); fNodalShapes->MeshFreeSupport().WriteNodalNeighbors(out); out.close(); /* nodal shape functions */ StringT shape_file = root; shape_file.Append(".", Name(), ".nodal_phi"); out.open(shape_file); fNodalShapes->MeshFreeSupport().WriteNodalShapes(out); out.close(); } // store shape function information for boundary integration fCellGeometry->BoundaryShapeFunctions(fBoundaryPhi, fBoundarySupports, fBoundaryFacetNormals); /* material Data */ ParameterListT mat_params; CollectMaterialInfo(list, mat_params); fMaterialList = NewMaterialList(mat_params.Name(), mat_params.NumLists()); if (!fMaterialList) ExceptionT::GeneralFail(caller,"could not construct material list \"%s\"", mat_params.Name().Pointer()); fMaterialList->TakeParameterList(mat_params); /* body force */ const ParameterListT* body_force = list.List("body_force"); if (body_force) { int schedule = body_force->GetParameter("schedule"); fBodySchedule = ElementSupport().Schedule(--schedule); /* body force vector */ const ArrayT<ParameterListT>& body_force_vector = body_force->Lists(); if (body_force_vector.Length() != NumDOF()) ExceptionT::BadInputValue(caller, "body force is length %d not %d", body_force_vector.Length(), NumDOF()); fBody.Dimension(NumDOF()); for (int i = 0; i < fBody.Length(); i++) fBody[i] = body_force_vector[i].GetParameter("value"); } /* extract natural boundary conditions */ TakeNaturalBC(list); /* output variables */ fOutputFlags.Dimension(kNumOutput); fOutputFlags = 0; const ParameterListT* output = list.List("scni_output"); if (output) { /* set flags */ for (int i = 0; i < kNumOutput; i++) { /* look for entry */ const ParameterT* value = output->Parameter(OutputNames[i]); if (value) { int do_write = *value; if (do_write) fOutputFlags[i] = 1; } } } }
/* 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 }
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 }