コード例 #1
0
ファイル: evac.c プロジェクト: LittleForker/the-omega-project
void study_evacuation(Conjunct *C, which_way dir, int max_arity)
    {
    if (evac_debug > 0)
	{
	assert(max_arity >= 0);

	if (max_arity > 0)
	    if (dir == in_to_out)
		{
		assert(max_arity <= C->relation()->n_inp());
		if (max_arity <= C->relation()->n_out())
		    single_evacs[study(C, input_vars, output_vars,
				       C->relation()->n_inp(),
				       C->relation()->n_out(),
				       max_arity)]++;
		}
	    else
		{
		assert(max_arity <= C->relation()->n_out());
		if (max_arity <= C->relation()->n_inp())
		    single_evacs[study(C, output_vars, input_vars,
				       C->relation()->n_out(),
				       C->relation()->n_inp(),
				       max_arity)]++;
		}
	}
    }
コード例 #2
0
ファイル: path.cpp プロジェクト: ksherlock/mpw-shell
	path path::extension() const {

		if (empty()) return *this;
		if (!_info.valid) study();

		return _path.substr(_info.extension);
	}
コード例 #3
0
ファイル: path.cpp プロジェクト: ksherlock/mpw-shell
	path path::parent_path() const {

		/*
		 * special cases:
		 * /abc -> /
		 * /abc/ -> /abc
		 * all trailing /s are removed.
		 *
		 */


		if (empty()) return *this;

		if (!_info.valid) study();

		// "/" is a file of "/" with a parent of ""
		if (_info.special == separator) return path();

		// stem starts at 0, eg "abc"
		if (!_info.stem) return path();


		auto tmp = _path.substr(0, _info.stem - 1);

		// remove trailing slashes, but return "/" if nothing BUT /s.
		while (!tmp.empty() && tmp.back() == separator) tmp.pop_back();
		if (tmp.empty()) return path_sep;

		return path(tmp);
	}
コード例 #4
0
ファイル: cmdline.cpp プロジェクト: neurocline/cmdline
bool cmdline::Cmdline::parse(int argc, char* argv[], bool noMixed)
{
	study();
	for (int i = 0; i < argc; i++)
	{
		argv[i];
	}
	noMixed;
	return true;
}
コード例 #5
0
void InstancesAccessed::addStudy(std::string studyInstanceUid, std::vector<SOPClass> sopClasses)
{
    EntityParticipantObject study(
        EntityParticipantObject::Type::SystemObject, EntityParticipantObject::Role::Report,
        generateParticipantObjectIDTypeCode(ParticipantObjectIDTypeCode::StudyInstanceUid),
        std::move(studyInstanceUid));

    study.setSOPClasses(std::move(sopClasses));
    studies.emplace_back(std::move(study));
}
コード例 #6
0
ファイル: path.cpp プロジェクト: ksherlock/mpw-shell
	path path::filename() const {

		if (empty()) return *this;
		if (!_info.valid) study();

		if (_info.special == separator) return path_sep;
		if (_info.special == '.') return path_dot;

		if (_info.stem == 0) return *this;
		return _path.substr(_info.stem);
	}
コード例 #7
0
ファイル: path.cpp プロジェクト: ksherlock/mpw-shell
	path path::stem() const {

		// filename without the extension.

		if (empty()) return *this;
		if (!_info.valid) study();

		if (_info.special == separator) return path_sep;
		if (_info.special == '.') return path_dot;

		return _path.substr(_info.stem, _info.extension - _info.stem);
	}
コード例 #8
0
ファイル: path.cpp プロジェクト: ksherlock/mpw-shell
	bool path::has_parent_path() const
	{
		// if there is a /, it has a parent path.
		// ... unless it's /.

		if (empty()) return false;

		if (!_info.valid) study();

		if (_info.special == '/') return false;

		return _path.find(separator) != _path.npos;
	}
コード例 #9
0
ファイル: evac.c プロジェクト: LittleForker/the-omega-project
void study_evacuation(Conjunct *C1, Conjunct *C2, int max_arity)
    {
    if (evac_debug > 0)
	{
	assert(max_arity >= 0);
	assert(max_arity <= C1->relation()->n_inp());
	assert(C2->relation()->n_out() == C1->relation()->n_inp());

	if (max_arity > 0)
	    if (max_arity <= C1->relation()->n_out() &&
		max_arity <= C2->relation()->n_inp())
		{
		double_evacs[study(C1, input_vars, output_vars, 
				   C1->relation()->n_inp(),
				   C1->relation()->n_out(),
				   max_arity)]
		    [study(C2, output_vars, input_vars,
			   C2->relation()->n_out(),
			   C2->relation()->n_inp(),
			   max_arity)]++;
		}
	    else if (max_arity <= C1->relation()->n_out())
		{
		single_evacs[study(C1, input_vars, output_vars,
				   C1->relation()->n_inp(),
				   C1->relation()->n_out(),
				   max_arity)]++;
		}
	    else if (max_arity <= C2->relation()->n_inp())
		{
		single_evacs[study(C2, output_vars, input_vars,
				   C2->relation()->n_out(),
				   C2->relation()->n_inp(),
				   max_arity)]++;
		}
	}
    }
コード例 #10
0
ファイル: rxx.C プロジェクト: gildafnai82/craq
str
rxx::init (const char *pat, const char *opt)
{
  extra = NULL;
  nsubpat = 0;
  ovector = NULL;
  bool studyit = false;

  int options = 0;
  for (; *opt; opt++)
    switch (*opt) {
    case '^':
      options |= PCRE_ANCHORED;
      break;
    case 'i':
      options |= PCRE_CASELESS;
      break;
    case 's':
      options |= PCRE_DOTALL;
      break;
    case 'm':
      options |= PCRE_MULTILINE;
      break;
    case 'x':
      options |= PCRE_EXTENDED;
      break;
    case 'U':
      options |= PCRE_UNGREEDY;
      break;
    case 'X':
      options |= PCRE_EXTRA;
      break;
    case 'S':
      studyit = true;
      break;
    default:
      return strbuf ("invalid regular expression option '%c'\n", *opt);
    }

  const char *errptr;
  int erroffset;
  re = pcre_compile (pat, options, &errptr, &erroffset, NULL);
  if (!re) {
    strbuf err;
    err << "Invalid regular expression:\n"
	<< "   " << pat << "\n";
    suio_fill (err.tosuio (), ' ', erroffset);
    err << "   ^\n"
	<< errptr << ".\n";
    return err;
  }
  if (studyit) {
    str err = study ();
    if (err)
      return strbuf () << "Could not study regular expression: " << err;
  }

  int ns = pcre_info (re, NULL, NULL);
  assert (ns >= 0);
  ovecsize = (ns + 1) * 3;
  return NULL;
}
コード例 #11
0
bool HConvergenceStudyTests::testBestApproximationErrorComputation() {
  bool success = true;

  bool enrichVelocity = false; // true would be for the "compliant" norm, which isn't working well yet
  
  int minLogElements = 0, maxLogElements = minLogElements;
  int numCells1D = pow(2.0,minLogElements);
  int H1Order = 1;
  int pToAdd = 2;
  
  double tol = 1e-16;
  double Re = 40.0;
  
  VarFactory varFactory = VGPStokesFormulation::vgpVarFactory();
  VarPtr u1_vgp = varFactory.fieldVar(VGP_U1_S);
  VarPtr u2_vgp = varFactory.fieldVar(VGP_U2_S);
  VarPtr sigma11_vgp = varFactory.fieldVar(VGP_SIGMA11_S);
  VarPtr sigma12_vgp = varFactory.fieldVar(VGP_SIGMA12_S);
  VarPtr sigma21_vgp = varFactory.fieldVar(VGP_SIGMA21_S);
  VarPtr sigma22_vgp = varFactory.fieldVar(VGP_SIGMA22_S);
  VarPtr p_vgp = varFactory.fieldVar(VGP_P_S);
  
  VGPStokesFormulation stokesForm(1/Re);
  
  int numCellsFineMesh = 20; // for computing a zero-mean pressure
  int H1OrderFineMesh = 5;
  
  // define Kovasznay domain:
  FieldContainer<double> quadPointsKovasznay(4,2);
  
  // Domain from Evans Hughes for Navier-Stokes:
  quadPointsKovasznay(0,0) =  0.0; // x1
  quadPointsKovasznay(0,1) = -0.5; // y1
  quadPointsKovasznay(1,0) =  1.0;
  quadPointsKovasznay(1,1) = -0.5;
  quadPointsKovasznay(2,0) =  1.0;
  quadPointsKovasznay(2,1) =  0.5;
  quadPointsKovasznay(3,0) =  0.0;
  quadPointsKovasznay(3,1) =  0.5;
  
  FunctionPtr zero = Function::zero();
  bool dontEnhanceFluxes = false;
  VGPNavierStokesProblem zeroProblem = VGPNavierStokesProblem(Re, quadPointsKovasznay,
                                                              numCellsFineMesh, numCellsFineMesh,
                                                              H1OrderFineMesh, pToAdd,
                                                              zero, zero, zero, enrichVelocity, dontEnhanceFluxes);
  
  FunctionPtr u1_exact, u2_exact, p_exact;
  NavierStokesFormulation::setKovasznay(Re, zeroProblem.mesh(), u1_exact, u2_exact, p_exact);
  
  
  VGPNavierStokesProblem problem = VGPNavierStokesProblem(Re,quadPointsKovasznay,
                                                          numCells1D,numCells1D,
                                                          H1Order, pToAdd,
                                                          u1_exact, u2_exact, p_exact, enrichVelocity, dontEnhanceFluxes);

  HConvergenceStudy study(problem.exactSolution(),
                          problem.mesh()->bilinearForm(),
                          problem.exactSolution()->rhs(),
                          problem.backgroundFlow()->bc(),
                          problem.bf()->graphNorm(),
                          minLogElements, maxLogElements,
                          H1Order, pToAdd, false, false, false);
  study.setReportRelativeErrors(false); // we want absolute errors

  Teuchos::RCP<Mesh> mesh = problem.mesh();
  
  int cubatureDegreeEnrichment = 10;
  
  int L2Order = H1Order - 1;
  int meshCubatureDegree = L2Order + H1Order + pToAdd;

  study.setCubatureDegreeForExact(cubatureDegreeEnrichment + meshCubatureDegree);
  
  FunctionPtr f = u1_exact;
  int trialID = u1_vgp->ID();
  {
    double fIntegral = f->integrate(mesh,cubatureDegreeEnrichment);
//    cout << "testBestApproximationErrorComputation: integral of f on whole mesh = " << fIntegral << endl;
    
    double l2ErrorOfAverage = (Function::constant(fIntegral) - f)->l2norm(mesh,cubatureDegreeEnrichment);
//    cout << "testBestApproximationErrorComputation: l2 error of fIntegral: " << l2ErrorOfAverage << endl;
    
    ElementTypePtr elemType = mesh->elementTypes()[0];
    vector<GlobalIndexType> cellIDs = mesh->cellIDsOfTypeGlobal(elemType);
    
    bool testVsTest = false;
    BasisCachePtr basisCache = Teuchos::rcp( new BasisCache(elemType, mesh, testVsTest, cubatureDegreeEnrichment) );
    basisCache->setPhysicalCellNodes(mesh->physicalCellNodesGlobal(elemType), cellIDs, false); // false: no side cache

    FieldContainer<double> projectionValues(cellIDs.size());
    f->integrate(projectionValues, basisCache);
    FieldContainer<double> cellMeasures = basisCache->getCellMeasures();
    
    for (int i=0; i<projectionValues.size(); i++) {
      projectionValues(i) /= cellMeasures(i);
    }
    
    // since we're not worried about the actual solution values at all, just use a single zero solution:
    vector< SolutionPtr > solutions;
    solutions.push_back( problem.backgroundFlow() );
    
    study.setSolutions(solutions); // this will call computeError()
    
    
    double approximationError = study.bestApproximationErrors()[trialID][0]; // 0: solution/mesh index
    
    // for a single-cell mesh, approximation error should be the same as the L^2 error of the average
    double diff = abs(approximationError - l2ErrorOfAverage);
  
    if (diff > tol) {
      cout << "testBestApproximationErrorComputation: diff " << diff << " exceeds tol " << tol << endl;
      success = false;
    } else {
//      cout << "testBestApproximationErrorComputation: diff " << diff << " is below tol " << tol << endl;
    }
  }
  return success;
}