コード例 #1
0
ファイル: Analysis.cpp プロジェクト: Rahjou/OpenStudio
 std::vector<DataPoint> Analysis_Impl::getDataPoints(
     const std::vector< boost::optional<DiscretePerturbation> >& perturbations) const
 {
   DataPointVector result;
   std::vector<QVariant> variableValues = problem().getVariableValues(perturbations);
   if (variableValues.size() == perturbations.size()) {
     // problem was able to match all perturbations
     result = getDataPoints(variableValues);
   }
   return result;
 }
コード例 #2
0
ファイル: main.cpp プロジェクト: sikhapol/CodeJam.cc
std::vector<Problem> map(int problems_count, std::vector<std::string> &lines) {
    
    std::vector<Problem> problems;
    auto it = lines.cbegin();
    for (int i = 0; i < problems_count; ++i) {
        Problem problem(it);
        problems.push_back(problem);
    }
    
    return problems;
}
コード例 #3
0
ファイル: assert_util.cpp プロジェクト: andradeandrey/mongo
    /* "warning" assert -- safe to continue, so we don't throw exception. */
    void wasserted(const char *msg, const char *file, unsigned line) {
        problem() << "warning Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
        sayDbContext();
        raiseError(0,msg && *msg ? msg : "wassertion failure");
        assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
        // this is so we notice in buildbot
        log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
        abort();
#endif
    }
コード例 #4
0
    /**
        Deletes the specified file. An exception is not thrown if the specified file does not exist

        \param[in]  path    The path to the file to be deleted.
        \throws     SCXUnauthorizedFileSystemAccessException    The caller does not have the required permission
                                                                or path is a directory or path specified a read-only file

        The path parameter is permitted to specify relative or absolute path information. Relative
        path information is interpreted as relative to the current working directory. To obtain
        the current working directory, see GetCurrentDirectory
     */
    void SCXFile::Delete(const SCXFilePath& path) {
#if defined(WIN32)
        int failure = _wremove(path.Get().c_str());
#elif defined(SCX_UNIX)
        std::string localizedPath = SCXFileSystem::EncodePath(path);
        int failure = remove(localizedPath.c_str());
#else
#error
#endif
        if (failure) {
            if (errno == EACCES || errno == EBUSY || errno == EPERM || errno == EROFS) {
                throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
            } else if (errno == ENOENT) {
                const int existenceOnly = 00;
#if defined(WIN32)
                failure = _waccess(path.Get().c_str(), existenceOnly);
#elif defined(SCX_UNIX)
                failure = access(localizedPath.c_str(), existenceOnly);
#else
#error
#endif
                bool fileStillExists = !failure;
                if (fileStillExists) {
                    // We got ENOENT when trying to remove the file,
                    // but appearently the file exists. That means that
                    // the file is not a file but a directory
                    throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
                } if (errno == EACCES) {
                    throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
                } else if (errno == EINVAL) {
                    throw SCXInvalidArgumentException(L"path", L"Invalid format of path " + path.Get(), SCXSRCLOCATION);
                } else if (errno != ENOENT) {
                    std::wstring problem(L"Failed to delete " + path.Get());
                    throw SCXInternalErrorException(UnexpectedErrno(problem, errno), SCXSRCLOCATION);
                }
            } else {
                std::wstring problem(L"Failed to delete " + path.Get());
                throw SCXInternalErrorException(UnexpectedErrno(problem, errno), SCXSRCLOCATION);
            }
        }
    }
コード例 #5
0
        void threadRun( MessagingPort * inPort) {
            assert( inPort );

            setThreadName( "conn" );
            TicketHolderReleaser connTicketReleaser( &connTicketHolder );

            auto_ptr<MessagingPort> p( inPort );

            string otherSide;

            Message m;
            try {
                otherSide = p->farEnd.toString();

                while ( 1 ) {
                    m.reset();
                    p->clearCounters();

                    if ( ! p->recv(m) ) {
                        if( !cmdLine.quiet )
                            log() << "end connection " << otherSide << endl;
                        p->shutdown();
                        break;
                    }

                    handler->process( m , p.get() );
                    networkCounter.hit( p->getBytesIn() , p->getBytesOut() );
                }
            }
            catch ( const SocketException& ) {
                log() << "unclean socket shutdown from: " << otherSide << endl;
            }
            catch ( const std::exception& e ) {
                problem() << "uncaught exception (" << e.what() << ")(" << demangleName( typeid(e) ) <<") in PortMessageServer::threadRun, closing connection" << endl;
            }
            catch ( ... ) {
                problem() << "uncaught exception in PortMessageServer::threadRun, closing connection" << endl;
            }

            handler->disconnected( p.get() );
        }
コード例 #6
0
ファイル: Analysis.cpp プロジェクト: Rahjou/OpenStudio
 bool Analysis_Impl::addDataPoint(const DataPoint& dataPoint) {
   if (m_dataPointsAreInvalid) {
     LOG(Info,"Current data points are invalid. Call removeAllDataPoints before adding new ones.");
     return false;
   }
   if (!(dataPoint.problem().uuid() == problem().uuid())) {
     LOG(Error,"Cannot add given DataPoint to Analysis '" << name() <<
         "', because it is not associated with Problem '" << problem().name() << "'.");
     return false;
   }
   DataPointVector existingDataPoints = getDataPoints(dataPoint.variableValues());
   if (existingDataPoints.size() > 0) {
     BOOST_ASSERT(existingDataPoints.size() == 1); // dataPoint must be fully specified to be valid
     LOG(Info,"DataPoint not added to Analysis '" << name() << "', because it already exists.");
     return false;
   }
   m_dataPoints.push_back(dataPoint);
   connectChild(m_dataPoints.back(),true);
   onChange(AnalysisObject_Impl::Benign);
   return true;
 }
コード例 #7
0
ファイル: assert_util.cpp プロジェクト: kapouer/mongo-debian
 void asserted(const char *msg, const char *file, unsigned line) {
     assertionCount.condrollover( ++assertionCount.regular );
     problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
     sayDbContext();
     raiseError(0,msg && *msg ? msg : "assertion failure");
     lastAssert[0].set(msg, getDbContext().c_str(), file, line);
     stringstream temp;
     temp << "assertion " << file << ":" << line;
     AssertionException e(temp.str(),0);
     breakpoint();
     throw e;
 }
コード例 #8
0
    void TestExceptions() throw(Exception)
    {
        TS_ASSERT_THROWS_THIS(MatrixVentilationProblem bad_problem("mesh/test/data/y_branch_3d_mesh", 1u),
                "Outlet node is not a boundary node");

        MatrixVentilationProblem problem("lung/test/data/three_bifurcations");
        TS_ASSERT_THROWS_THIS(problem.SolveProblemFromFile("DoesNotExist.txt", "out", "out"), "Could not open file DoesNotExist.txt");

        TS_ASSERT_THROWS_THIS(problem.SetPressureAtBoundaryNode(3u, 0.0), "Boundary conditions cannot be set at internal nodes");
        TS_ASSERT_THROWS_THIS(problem.SetFluxAtBoundaryNode(3u, 0.0), "Boundary conditions cannot be set at internal nodes");

    }
コード例 #9
0
ファイル: ilp_problem.cpp プロジェクト: naoya-i/phillip
void ilp_solution_t::get_reduced_sol(std::set<literal_t> *p_literals, std::set<literal_t> *p_non_eqs, const std::list< hash_set<term_t> > &terms) const {

    const ilp_problem_t *prob = problem();
    const pg::proof_graph_t *graph = prob->proof_graph();
    hash_map<term_t, term_t> t2r;

    _getRepresentative(&t2r, terms);

    auto reguralized =
        [&t2r](const std::list<hash_set<term_t> > &terms, const literal_t &lit) -> literal_t
    {
        literal_t out(lit);
        for (term_idx_t i = 0; i < out.terms.size(); ++i)
        {
            if (t2r.count(out.terms.at(i)) > 0)
            {
                out.terms[i] = t2r[out.terms.at(i)];
                break;
            }
        }
        return out;
    };

    // ENUMERATE ELEMENTS OF literals AND non_eqs
    for (auto n : graph->nodes())
    if (not n.is_equality_node())
    if (n.type() == pg::NODE_HYPOTHESIS or n.type() == pg::NODE_OBSERVABLE)
    {
        variable_idx_t v = problem()->find_variable_with_node(n.index());

        if (v >= 0)
        if (variable_is_active(v))
        {
            if (n.is_non_equality_node())
                p_non_eqs->insert(reguralized(terms, n.literal()));
            else
                p_literals->insert(reguralized(terms, n.literal()));
        }
    }
}
コード例 #10
0
void
InitPolicyInterpolation< mesh_Type >::
initSimulation ( bcContainerPtr_Type /*bchandler*/,
                 vectorPtr_Type solution )
{
    ASSERT ( problem()->hasExactSolution(), "Error: You cannot use the interpolation method if the problem has not an analytical solution." );

    Real currentTime = initialTime() - timestep() * bdf()->order();
    UInt pressureOffset = uFESpace()->fieldDim() * uFESpace()->dof().numTotalDof();

    vectorPtr_Type velocity;
    velocity.reset ( new vector_Type ( uFESpace()->map(), Unique ) );

    vectorPtr_Type pressure;
    pressure.reset ( new vector_Type ( pFESpace()->map(), Unique ) );

    *solution = 0.0;
    uFESpace()->interpolate ( problem()->uexact(), *velocity, currentTime );
    pFESpace()->interpolate ( problem()->pexact(), *pressure, currentTime );
    solution->add ( *velocity );
    solution->add ( *pressure, pressureOffset );
    bdf()->setInitialCondition ( *solution );

    currentTime += timestep();
    for ( ; currentTime <=  initialTime() + timestep() / 2.0; currentTime += timestep() )
    {
        *solution = 0.0;
        *velocity = 0.0;
        *pressure = 0.0;

        uFESpace()->interpolate ( problem()->uexact(), *velocity, currentTime );
        pFESpace()->interpolate ( problem()->pexact(), *pressure, currentTime );
        solution->add ( *velocity );
        solution->add ( *pressure, pressureOffset );

        // Updating bdf
        bdf()->shiftRight ( *solution );
    }
}
コード例 #11
0
ファイル: conflicting_writes.c プロジェクト: IvanMalison/grid
void conflicting_writes(host_port *host) {
  int connection, err;
  err = make_connection_with(host->ip, host->port, &connection);
  if(err < 0) {
    problem("Connection failure.\n");
    exit(-1);
  }
  printf("Made connection in second thread, file descriptor is %d\n", connection);
  err = DONT;
  safe_send(connection, &err, sizeof(int));
  err = 3000;
  safe_send(connection, &err, sizeof(int));	     
}
コード例 #12
0
ファイル: sock.cpp プロジェクト: mharris717/mongo
        SockStartupTests() {
#if defined(_WIN32)
            WSADATA d;
            if ( WSAStartup(MAKEWORD(2,2), &d) != 0 ) {
                out() << "ERROR: wsastartup failed " << errno << endl;
                problem() << "ERROR: wsastartup failed " << errno << endl;
                dbexit( EXIT_NTSERVICE_ERROR );
            }
#endif
            //out() << "ntohl:" << ntohl(256) << endl;
            //sendtest();
            //listentest();
        }
コード例 #13
0
ファイル: main.cpp プロジェクト: Artifere/Rendu1
int main(int argc, char *argv[])
{
    // Pour accélérer les I/O
    //std::ios_base::sync_with_stdio(false);
    if(argc != 2)
    {
        std::cerr << "Nombre d'argument invalide : un unique argument est attendu." << std::endl;
        exit(1);
    }

    std::ifstream input;
    input.open (argv[1], std::ios::in);
    if (!input.is_open())
    {
        std::cerr << "Erreur dans l'ouverture du fichier " << argv[1] << std::endl;
        exit(1);
    }
    // Parse le header dans l'entrée standard : récupère nombre de variables et de clauses
    unsigned int nbrVar, nbrClauses;
    parserHeader(input, nbrVar, nbrClauses);
    // Initialise le problème en lisant l'entrée standard
    SatProblem problem(input, nbrVar, nbrClauses);
    input.close();
    // Résout le problème puis affiche la sortie correspondante
    #if VERBOSE == 0
    if (problem.satisfiability())
        return EXIT_SATISFIABLE;
    else
        return EXIT_UNSATISFIABLE;
    #else
    if(problem.satisfiability())
    {
        std::cout << "s SATISFIABLE\n";
        const std::vector<std::pair<unsigned, bool> > assign = problem.getAssign();
        for(unsigned int k = 0; k < assign.size(); k++)
        {
            std::cout << "v ";
            if (! assign[k].second)
                std::cout << "-";
            std::cout << assign[k].first << '\n';
        }
        return EXIT_SATISFIABLE;
    }
    else
    {
        std::cout << "s UNSATISFIABLE\n";
        return EXIT_UNSATISFIABLE;
    }
    #endif

}
コード例 #14
0
ファイル: solve.cpp プロジェクト: alogg/dolfin
//-----------------------------------------------------------------------------
void dolfin::solve(const Equation& equation,
                   Function& u,
                   std::vector<const BoundaryCondition*> bcs,
		   Parameters parameters)
{
  // Solve linear problem
  if (equation.is_linear())
  {
    LinearVariationalProblem problem(*equation.lhs(), *equation.rhs(), u, bcs);
    LinearVariationalSolver solver(problem);
    solver.parameters.update(parameters);
    solver.solve();
  }

  // Solve nonlinear problem
  else
  {
    NonlinearVariationalProblem problem(*equation.lhs(), u, bcs);
    NonlinearVariationalSolver solver(problem);
    solver.parameters.update(parameters);
    solver.solve();
  }
}
コード例 #15
0
ファイル: index_update.cpp プロジェクト: ChowZenki/mongo
    /**
     * Remove the provided (obj, dl) pair from the provided index.
     */
    static void _unindexRecord(NamespaceDetails *d, int idxNo, const BSONObj& obj,
                               const DiskLoc& dl, bool logIfError = true) {
        auto_ptr<IndexDescriptor> desc(CatalogHack::getDescriptor(d, idxNo));
        auto_ptr<IndexAccessMethod> iam(CatalogHack::getIndex(desc.get()));
        InsertDeleteOptions options;
        options.logIfError = logIfError;

        int64_t removed;
        Status ret = iam->remove(obj, dl, options, &removed);
        if (Status::OK() != ret) {
            problem() << "Couldn't unindex record " << obj.toString() << " status: "
                << ret.toString() << endl;
        }
    }
コード例 #16
0
ファイル: dbhelpers.cpp プロジェクト: mapleoin/mongo
 DbSet::~DbSet() {
     if ( name_.empty() )
         return;
     try {
         Client::Context c( name_.c_str() );
         if ( nsdetails( name_.c_str() ) ) {
             string errmsg;
             BSONObjBuilder result;
             dropCollection( name_, errmsg, result );
         }
     } catch ( ... ) {
         problem() << "exception cleaning up DbSet" << endl;
     }
 }
コード例 #17
0
ファイル: Analysis.cpp プロジェクト: Zicao/OpenStudio
 boost::optional<DataPoint> Analysis_Impl::getDataPoint(
     const std::vector<Measure>& measures) const
 {
   OptionalDataPoint result;
   std::vector<QVariant> variableValues = problem().getVariableValues(measures);
   if (variableValues.size() == measures.size()) {
     // problem was able to match all measures
     DataPointVector intermediate = getDataPoints(variableValues);
     OS_ASSERT(intermediate.size() < 2u);
     if (intermediate.size() == 1u) {
       result = intermediate[0];
     }
   }
   return result;
 }
コード例 #18
0
ファイル: server.c プロジェクト: IvanMalison/grid
int get_servers(char *hostname, int port, int add_slots, host_list **list) {
  int connection = 0;
  int result = 0;
  int err;
  err = make_connection_with(hostname, port, &connection);
  if(err < 0) {
    problem("Failed to connect to retrive servers");
    return FAILURE;
  }
  err = SEND_SERVERS;
  do_rpc(&err);
  result = receive_host_list(connection, list);
  close(connection);
  return result;
}
コード例 #19
0
ファイル: instance.cpp プロジェクト: Thor1Khan/mongo
 void DiagLog::openFile() {
     verify( f == 0 );
     stringstream ss;
     ss << dbpath << "/diaglog." << hex << time(0);
     string name = ss.str();
     f = new ofstream(name.c_str(), ios::out | ios::binary);
     if ( ! f->good() ) {
         problem() << "diagLogging couldn't open " << name << endl;
         // todo what is this? :
         throw 1717;
     }
     else {
         log() << "diagLogging using file " << name << endl;
     }
 }
コード例 #20
0
ファイル: Analysis.cpp プロジェクト: Rahjou/OpenStudio
 boost::optional<DataPoint> Analysis_Impl::getDataPoint(
     const std::vector<DiscretePerturbation>& perturbations) const
 {
   OptionalDataPoint result;
   std::vector<QVariant> variableValues = problem().getVariableValues(perturbations);
   if (variableValues.size() == perturbations.size()) {
     // problem was able to match all perturbations
     DataPointVector intermediate = getDataPoints(variableValues);
     BOOST_ASSERT(intermediate.size() < 2u);
     if (intermediate.size() == 1u) {
       result = intermediate[0];
     }
   }
   return result;
 }
コード例 #21
0
  void FluctuatingChargePropagator::initialize() {
    if (info_->usesFluctuatingCharges()) {
      if (info_->getNFluctuatingCharges() > 0) {
        hasFlucQ_ = true;
	fqConstraints_ = new FluctuatingChargeConstraints(info_);
	fqConstraints_->setConstrainRegions(fqParams_->getConstrainRegions());
      }
    }
    
    if (!hasFlucQ_) {
      initialized_ = true;
      return;
    }

    // SimInfo::MoleculeIterator i;
    // Molecule::FluctuatingChargeIterator  j;
    // Molecule* mol;
    // Atom* atom;
    //  
    // For single-minima flucq, this ensures a net neutral system, but
    // for multiple minima, this is no longer the right thing to do:
    //
    // for (mol = info_->beginMolecule(i); mol != NULL; 
    //      mol = info_->nextMolecule(i)) {
    //   for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
    //        atom = mol->nextFluctuatingCharge(j)) {
    //     atom->setFlucQPos(0.0);
    //     atom->setFlucQVel(0.0);
    //   }
    // }
    
    FluctuatingChargeObjectiveFunction flucQobjf(info_, forceMan_, 
                                                 fqConstraints_);

    DynamicVector<RealType> initCoords = flucQobjf.setInitialCoords();
    Problem problem(flucQobjf, *(new NoConstraint()), *(new NoStatus()), 
                    initCoords);

    EndCriteria endCriteria(1000, 100, 1e-5, 1e-5, 1e-5);       

    OptimizationMethod* minim = OptimizationFactory::getInstance()->createOptimization("SD", info_);

    DumpStatusFunction dsf(info_);  // we want a dump file written
                                    // every iteration
    minim->minimize(problem, endCriteria);
    cerr << "back from minim\n";
    initialized_ = true;
  }
コード例 #22
0
ファイル: clientcursor.cpp プロジェクト: erickt/mongo
    /* must call this on a delete so we clean up the cursors. */
    void ClientCursor::aboutToDelete(const DiskLoc& dl) {
        recursive_scoped_lock lock(ccmutex);

        CCByLoc::iterator j = byLoc.lower_bound(dl);
        CCByLoc::iterator stop = byLoc.upper_bound(dl);
        if ( j == stop )
            return;

        vector<ClientCursor*> toAdvance;

        while ( 1 ) {
            toAdvance.push_back(j->second);
            DEV assert( j->first == dl );
            ++j;
            if ( j == stop )
                break;
        }

        wassert( toAdvance.size() < 5000 );
        
        for ( vector<ClientCursor*>::iterator i = toAdvance.begin(); i != toAdvance.end(); ++i ){
            ClientCursor* cc = *i;
            
            if ( cc->_doingDeletes ) continue;

            Cursor *c = cc->c.get();
            if ( c->capped() ){
                delete cc;
                continue;
            }
            
            c->checkLocation();
            DiskLoc tmp1 = c->refLoc();
            if ( tmp1 != dl ) {
                /* this might indicate a failure to call ClientCursor::updateLocation() */
                problem() << "warning: cursor loc " << tmp1 << " does not match byLoc position " << dl << " !" << endl;
            }
            c->advance();
            if ( c->eof() ) {
                // advanced to end -- delete cursor
                delete cc;
            }
            else {
                wassert( c->refLoc() != dl );
                cc->updateLocation();
            }
        }
    }
コード例 #23
0
ファイル: assert_util.cpp プロジェクト: Eric-Lu/mongo
    NOINLINE_DECL void verifyFailed( int msgid ) {
        assertionCount.condrollover( ++assertionCount.regular );
        problem() << "Assertion failure " << msgid << endl;
        sayDbContext();
        raiseError(0,"assertion failure");
        stringstream temp;
        temp << msgid;
        AssertionException e(temp.str(),0);
        breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
        // this is so we notice in buildbot
        log() << "\n\n***aborting after verify() failure in a debug/test build\n\n" << endl;
        abort();
#endif
        throw e;
    }
コード例 #24
0
ファイル: server.c プロジェクト: IvanMalison/grid
int update_job_counts(host_list *update) {
  host_list_node *my_runner, *update_runner;
  my_runner = server_list->head;
  update_runner = update->head;
  do {
    if(my_runner->host->id != update_runner->host->id) {
      problem("Heartbeat update did not agree with our current serverlist.\n");
    }
    if(my_runner->host->time_stamp < update_runner->host->time_stamp) {
      my_runner->host->time_stamp = update_runner->host->time_stamp;
      my_runner->host->jobs = update_runner->host->jobs;
    }
    my_runner = my_runner->next;
    update_runner = update_runner->next;
  } while(my_runner != server_list->head);  
}
コード例 #25
0
void
ProblemListenerDefault::problem(
			eProblemSource				where,
			eClassification				classification,
			const XalanNode*			sourceNode,
			const ElemTemplateElement*	styleNode,
			const XalanDOMString&		msg,
			const XalanDOMChar*			uri,
			int							lineNo,
			int							charOffset)
{
	if (m_pw != 0)
	{
		problem(*m_pw, where, classification, sourceNode, styleNode, msg, uri, lineNo, charOffset);
	}
}
コード例 #26
0
ファイル: assert_util.cpp プロジェクト: 89snake89/mongo
    NOINLINE_DECL void verifyFailed(const char *msg, const char *file, unsigned line) {
        assertionCount.condrollover( ++assertionCount.regular );
        problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
        logContext();
        setLastError(0,msg && *msg ? msg : "assertion failure");
        stringstream temp;
        temp << "assertion " << file << ":" << line;
        AssertionException e(temp.str(),0);
        breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
        // this is so we notice in buildbot
        log() << "\n\n***aborting after verify() failure as this is a debug/test build\n\n" << endl;
        abort();
#endif
        throw e;
    }
コード例 #27
0
 void TestSineThreeBifurcations() throw (Exception)
 {
     MatrixVentilationProblem problem("lung/test/data/three_bifurcations", 0u);
     problem.SetRadiusOnEdge();
     problem.SetOutflowPressure(0.0);
     TimeStepper stepper(0.0, 25.0, 0.1);
     problem.SolveOverTime(stepper, &SineBCs, "TestVentilation", "three_bifurcations_sine");
     std::vector<double> flux, pressure;
     problem.GetSolutionAsFluxesAndPressures(flux, pressure); //check pressure at end time @ 25
     TS_ASSERT_DELTA(pressure[0], 0.0,     1e-8); //BC
     TS_ASSERT_DELTA(pressure[1], 5.7655,  1e-4);
     TS_ASSERT_DELTA(pressure[2], 10.5701, 1e-4);
     TS_ASSERT_DELTA(pressure[3], 10.5701, 1e-4);
     TS_ASSERT_DELTA(pressure[4], 12.972452, 1e-5); //BC
     TS_ASSERT_DELTA(pressure[5], 12.972452, 1e-5); //BC
 }
コード例 #28
0
static void
fetch_srgba_dxt5(const GLubyte *map,
                 GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
   if (fetch_ext_rgba_dxt5) {
      GLubyte tex[4];
      fetch_ext_rgba_dxt5(rowStride, map, i, j, tex);
      texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
      texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
      texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
      texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
   }
   else {
      problem("srgba_dxt5");
   }
}
コード例 #29
0
static void
fetch_rgba_dxt3(const GLubyte *map,
                GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
   if (fetch_ext_rgba_dxt3) {
      GLubyte tex[4];
      fetch_ext_rgba_dxt3(rowStride, map, i, j, tex);
      texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
      texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
      texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
      texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
   }
   else {
      problem("rgba_dxt3");
   }
}
コード例 #30
0
    void TestTopOfAirwaysPatientDataOutflowFlux() throw (Exception)
    {
        MatrixVentilationProblem problem("lung/test/data/top_of_tree", 0u);
        PetscTools::SetOption("-ksp_monitor", "");
        problem.SetOutflowFlux(0.001);
        problem.SetConstantInflowPressures(50.0);
        //problem.SetConstantInflowFluxes(100.0);
        TetrahedralMesh<1, 3>& r_mesh=problem.rGetMesh();
        TS_ASSERT_EQUALS(r_mesh.GetNumNodes(), 31u);
        TS_ASSERT_EQUALS(r_mesh.GetNumElements(), 30u);
        problem.Solve();

        std::vector<double> flux, pressure;
        problem.GetSolutionAsFluxesAndPressures(flux, pressure);
        TS_ASSERT_DELTA(flux[0], 0.001, 1e-5);
    }