Пример #1
0
/**
@todo JSON access errors lack specifier
@todo Check that omegas ar filled/exits
@todo Clean up nested checks for optional JSON arguments
@todo Eigenvalues should be computed independent of json output,
stored and used twice, for screen and file
*/
void run(const Settings &s) {
  // empty configurators
  unique_ptr<csmp::tperm::Configurator> mconf =
      make_unique<csmp::tperm::NullConfigurator>();
  unique_ptr<csmp::tperm::Configurator> fconf =
      make_unique<csmp::tperm::NullConfigurator>();
  // get matrix configurator
  Settings cs(s, "configuration");
  if (cs.json.count("matrix")) {
    Settings mcs(cs, "matrix");
    mconf = MatrixConfiguratorFactory().configurator(mcs);
  }
  // get fracture configurator
  if (cs.json.count("fractures")) {
    Settings fcs(cs, "fractures");
    fconf = FractureConfiguratorFactory().configurator(fcs);
  }
  // get omega generator
  Settings acs(s, "analysis");
  auto ogen = make_omega_generator(acs);
  // load model...
  Settings ms(s, "model");
  auto model = load_model(ms);
  // configure material properties
  mconf->configure(*model);
  fconf->configure(*model);
  // sort boundaries
  auto bds = sort_boundaries(*model, s);
  // ready to solve
  solve(bds, *model);
  // generate omegas
  auto omegas = ogen->generate(*model);
  auto nomegas = named_omegas(omegas);
  // get upscaled tensors
  auto omega_tensors = fetch(*model, nomegas);
  // results
  string jres_fname = "";
  if (s.json.count("output")) {
    Settings outs(s, "output");
    if (outs.json.count("save final binary")) // write to csmp binary
      if (outs.json["save final binary"].get<string>() != "")
        save_model(*model,
                   outs.json["save final binary"].get<string>().c_str());
    if (outs.json.count("vtu")) { // write to vtu
      if (outs.json["vtu"].get<bool>()) {
        make_omega_regions(nomegas, *model);
        vtu(omega_tensors, *model);
      }
      if (outs.json.count("vtu regions"))
        vtu(outs.json["vtu regions"].get<vector<string>>(), *model);
    }
    if (outs.json.count("results file name")) // write to json
      jres_fname = s.json["output"]["results file name"].get<string>();
  }
  report(omega_tensors, *model, jres_fname.c_str());
}
Пример #2
0
// Reload config values from the specified ConfigSource
void Configurator::config_load_command( string parameters, StreamOutput* stream ){
    string source = shift_parameter(parameters);
    if(source == ""){
        this->kernel->config->config_cache_load();
        this->kernel->call_event(ON_CONFIG_RELOAD);
        stream->printf( "Reloaded settings\r\n" );
    } else if(file_exists(source)){
        FileConfigSource fcs(source);
        fcs.transfer_values_to_cache(&this->kernel->config->config_cache);
        this->kernel->call_event(ON_CONFIG_RELOAD);
        stream->printf( "Loaded settings from %s\r\n", source.c_str() );
    } else {
        uint16_t source_checksum = get_checksum(source);
        for(int i=0; i < this->kernel->config->config_sources.size(); i++){
            if( this->kernel->config->config_sources[i]->is_named(source_checksum) ){
                this->kernel->config->config_sources[i]->transfer_values_to_cache(&this->kernel->config->config_cache);
                this->kernel->call_event(ON_CONFIG_RELOAD);
                stream->printf( "Loaded settings from %s\r\n", source.c_str() );
                break;
            }
        }
    }
}
Пример #3
0
void Foam::vtkPVFoam::convertMeshPatches
(
    vtkMultiBlockDataSet* output,
    int& blockNo
)
{
    arrayRange& range = arrayRangePatches_;
    range.block(blockNo);      // set output block
    label datasetNo = 0;       // restart at dataset 0
    const fvMesh& mesh = *meshPtr_;
    const polyBoundaryMesh& patches = mesh.boundaryMesh();

    if (debug)
    {
        Info<< "<beg> Foam::vtkPVFoam::convertMeshPatches" << endl;
        printMemory();
    }

    for (int partId = range.start(); partId < range.end(); ++partId)
    {
        if (!partStatus_[partId])
        {
            continue;
        }

        const word patchName = getPartName(partId);

        labelHashSet
            patchIds(patches.patchSet(List<wordRe>(1, wordRe(patchName))));

        if (debug)
        {
            Info<< "Creating VTK mesh for patches [" << patchIds <<"] "
                << patchName << endl;
        }

        vtkPolyData* vtkmesh = nullptr;
        if (patchIds.size() == 1)
        {
            vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]);
        }
        else
        {
            // Patch group. Collect patch faces.
            label sz = 0;
            forAllConstIter(labelHashSet, patchIds, iter)
            {
                sz += patches[iter.key()].size();
            }
            labelList meshFaceLabels(sz);
            sz = 0;
            forAllConstIter(labelHashSet, patchIds, iter)
            {
                const polyPatch& pp = patches[iter.key()];
                forAll(pp, i)
                {
                    meshFaceLabels[sz++] = pp.start()+i;
                }
            }
            UIndirectList<face> fcs(mesh.faces(), meshFaceLabels);
            uindirectPrimitivePatch pp(fcs, mesh.points());

            vtkmesh = patchVTKMesh(patchName, pp);
        }


        if (vtkmesh)
        {
            AddToBlock(output, vtkmesh, range, datasetNo, patchName);
            vtkmesh->Delete();

            partDataset_[partId] = datasetNo++;
        }
    }