Albany::SimMeshStruct::SimMeshStruct(
    const Teuchos::RCP<Teuchos::ParameterList>& params,
		const Teuchos::RCP<const Teuchos_Comm>& commT)
{
  SimUtil_start();
  Sim_readLicenseFile(0);
  MS_init();
  SimPartitionedMesh_start(NULL, NULL);
  gmi_sim_start();
  gmi_register_sim();
  PCU_Comm_Init();

  params->validateParameters(
      *(SimMeshStruct::getValidDiscretizationParameters()), 0);

  outputFileName = params->get<std::string>("Sim Output File Name", "");
  outputInterval = params->get<int>("Sim Write Interval", 1); // write every time step default

  std::string native_file;
  if (params->isParameter("Acis Model Input File Name"))
    native_file = params->get<std::string>("Parasolid Model Input File Name");
  if(params->isParameter("Parasolid Model Input File Name"))
    native_file = params->get<std::string>("Parasolid Model Input File Name");
  std::string smd_file;
  if(params->isParameter("Sim Model Input File Name"))
    smd_file = params->get<std::string>("Sim Model Input File Name");

  model = gmi_sim_load(native_file.empty() ? 0 : native_file.c_str(),
                       smd_file.empty()    ? 0 : smd_file.c_str());
  pGModel sim_model = gmi_export_sim(model);

  std::string mesh_file = params->get<std::string>("Sim Input File Name");
  pParMesh sim_mesh = PM_load(mesh_file.c_str(), sthreadNone, sim_model, NULL);
  mesh = apf::createMesh(sim_mesh);

  APFMeshStruct::init(params, commT);

  if (params->isParameter("Sim Restart File Name")) {
    std::cerr << "reading solution from file!\n";
    hasRestartSolution = true;
    assert(!params->isParameter("Solution Vector Components"));
    std::string field_file = params->get<std::string>("Sim Restart File Name");
    pField sim_field = Field_load(field_file.c_str(), sim_mesh, 0, 0);
    apf::Field* field = apf::wrapSIMField(mesh, sim_field);
    std::string name = apf::getName(field);
    if (name != Albany::APFMeshStruct::solution_name) {
      std::cerr << "renaming restart field \"" << name << "\" to \""
        << Albany::APFMeshStruct::solution_name << "\"\n";
      apf::renameField(field, Albany::APFMeshStruct::solution_name);
    }
    restartDataTime = params->get<double>("Sim Restart Time", 0);
    solutionInitialized = true;
    apf::writeVtkFiles("restarted", mesh);
  }
}
Beispiel #2
0
int main(int argc, char* argv[]) {
  MPI_Init(&argc,&argv);
  PCU_Comm_Init();
  PCU_Debug_Open();
  if ( argc != 2&&argc!=3 ) {
    if ( !PCU_Comm_Self() )
      printf("Usage: %s <binary_graph_file> [vertex_partition_file]",argv[0]);
    PCU_Comm_Free();
    MPI_Finalize();
    assert(false);
  }
  agi::binGraph* g;
  zagi::ZoltanCutVertex* ptn;
  int self = PCU_Comm_Self();
  int num_parts = PCU_Comm_Peers();
  PCU_Switch_Comm(MPI_COMM_SELF);
  if (!self) {

    g = new agi::binGraph(argv[1]);
    ptn = new zagi::ZoltanCutVertex(g,num_parts);
    ptn->run();
  }
  else
    g = new agi::binGraph();
  agi::EdgePartitionMap map;
  if (!self) {
    ptn->createPtn(map);
    delete ptn;
  }

  PCU_Switch_Comm(MPI_COMM_WORLD);
  g->migrate(map);

  partitionInfo(g);

  delete g;

  if (!PCU_Comm_Self())
    printf("Block Partitioning\n");

  g = new agi::binGraph(argv[1]);

  partitionInfo(g);

  delete g;

  if (argc==3) {
  if (!PCU_Comm_Self())
    printf("Partitioned: %s\n",argv[2]);
    g = new agi::binGraph(argv[1],argv[2]);
    partitionInfo(g);
    delete g;
  }

  PCU_Barrier();
  if (!PCU_Comm_Self())
    printf("\nAll tests passed\n");

  PCU_Comm_Free();
  MPI_Finalize();

}
Albany::PUMIMeshStruct::PUMIMeshStruct(
    const Teuchos::RCP<Teuchos::ParameterList>& params,
		const Teuchos::RCP<const Teuchos_Comm>& commT)
{
  PCU_Comm_Init();
  params->validateParameters(
      *(PUMIMeshStruct::getValidDiscretizationParameters()), 0);

  outputFileName = params->get<std::string>("PUMI Output File Name", "");
  outputInterval = params->get<int>("PUMI Write Interval", 1); // write every time step default

  gmi_register_mesh();

  std::string model_file;
  if(params->isParameter("Mesh Model Input File Name"))
    model_file = params->get<std::string>("Mesh Model Input File Name");

#ifdef SCOREC_SIMMODEL
  Sim_readLicenseFile(0);
  gmi_sim_start();
  gmi_register_sim();

  if (params->isParameter("Acis Model Input File Name"))
    model_file = params->get<std::string>("Parasolid Model Input File Name");

  if(params->isParameter("Parasolid Model Input File Name"))
    model_file = params->get<std::string>("Parasolid Model Input File Name");
#endif

  if (params->isParameter("PUMI Input File Name")) {

    std::string mesh_file = params->get<std::string>("PUMI Input File Name");
    mesh = 0;
    
    // If we are running in parallel but have a single mesh file, split it and rebalance
    bool useSerialMesh = params->get<bool>("Use Serial Mesh", false);
    if (useSerialMesh && commT->getSize() > 1){ // do the equivalent of the SCOREC "split" utility
       apf::Migration* plan = 0;
       gmi_model* g = 0;
       g = gmi_load(model_file.c_str());
       bool isOriginal = ((PCU_Comm_Self() % commT->getSize()) == 0);
       switchToOriginals(commT->getSize());
       if (isOriginal) {
         mesh = apf::loadMdsMesh(g, mesh_file.c_str());
         plan = getPlan(mesh, commT->getSize());
       }
       switchToAll();
       mesh = repeatMdsMesh(mesh, g, plan, commT->getSize());
    }
    else {
      mesh = apf::loadMdsMesh(model_file.c_str(), mesh_file.c_str());
    }

  } else {
    int nex = params->get<int>("1D Elements", 0);
    int ney = params->get<int>("2D Elements", 0);
    int nez = params->get<int>("3D Elements", 0);
    double wx = params->get<double>("1D Scale", 1);
    double wy = params->get<double>("2D Scale", 1);
    double wz = params->get<double>("3D Scale", 1);
    bool is = ! params->get<bool>("Hexahedral", true);
    buildBoxMesh(nex, ney, nez, wx, wy, wz, is);
  }

  model = mesh->getModel();

  // Tell the mesh that we'll handle deleting the model.
  apf::disownMdsModel(mesh);

  bool isQuadMesh = params->get<bool>("2nd Order Mesh",false);
  if (isQuadMesh)
    apf::changeMeshShape(mesh, apf::getSerendipity(), false);

  // Resize mesh after input if indicated in the input file
  // User has indicated a desired element size in input file
  if(params->isParameter("Resize Input Mesh Element Size")){
    SizeFunction sizeFunction(params->get<double>(
          "Resize Input Mesh Element Size", 0.1));
    int num_iters = params->get<int>(
        "Max Number of Mesh Adapt Iterations", 1);
    ma::Input* input = ma::configure(mesh,&sizeFunction);
    input->maximumIterations = num_iters;
    input->shouldSnap = false;
    ma::adapt(input);
  }

  APFMeshStruct::init(params, commT);
}