本文整理汇总了C++中solve函数的典型用法代码示例。如果您正苦于以下问题:C++ solve函数的具体用法?C++ solve怎么用?C++ solve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了solve函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
// search_space();
solve(112, true);
return 0;
}
开发者ID:cohadar,项目名称:math-puzzles,代码行数:6,代码来源:shaolin_steps.c
示例2: main
int main()
{
while(EOF!=scanf("%d",&N) && 0!=N)
solve();
return 0;
}
开发者ID:GadyPu,项目名称:OnlineJudge,代码行数:6,代码来源:1315+Don't+Get+Rooked.c
示例3: main
int main()
{
printf("%d\n", solve());
return 0;
}
开发者ID:zhangsen,项目名称:project-euler,代码行数:5,代码来源:19-sunday-on-first.c
示例4: maxDamage
int maxDamage(vector <int> level, vector <int> damage)
{
memset(dp,-1,sizeof dp);
return solve(level,damage,0,0);
}
开发者ID:osama-afifi,项目名称:Online-Judges-Solutions,代码行数:6,代码来源:SRM+563.cpp
示例5: permute
vector<vector<int>> permute(vector<int>& nums) {
if (nums.size() <= 1)
return {nums};
solve(0, nums);
return permutations;
}
开发者ID:hkoehler,项目名称:LeetCode,代码行数:6,代码来源:permutations.cpp
示例6: main
int main( int argc, char *argv[] )
{
if ( (argc == 2) &&
( (GF2::console::find_switch(argc,argv,"--help"))
|| (GF2::console::find_switch(argc,argv,"-h" ))
)
)
{
std::cout << "[Usage]:\n"
<< "\t--generate\n"
<< "\t--generate3D\n"
<< "\t--formulate\n"
<< "\t--formulate3D\n"
<< "\t--solver mosek|bonmin|gurobi\n"
<< "\t--solver3D mosek|bonmin|gurobi\n"
<< "\t--merge\n"
<< "\t--merge3D\n"
<< "\t--datafit\n"
<< "\t--corresp\n"
//<< "\t--show\n"
<< std::endl;
return EXIT_SUCCESS;
}
else if ( GF2::console::find_switch(argc,argv,"--segment") || GF2::console::find_switch(argc,argv,"--segment3D") )
{
return segment( argc, argv );
}
else if ( GF2::console::find_switch(argc,argv,"--generate") || GF2::console::find_switch(argc,argv,"--generate3D") )
{
return generate(argc,argv);
}
else if ( GF2::console::find_switch(argc,argv,"--formulate") || GF2::console::find_switch(argc,argv,"--formulate3D"))
{
return formulate( argc, argv );
//return GF2::ProblemSetup::formulateCli<GF2::Solver::PrimitiveContainerT, GF2::Solver::PointContainerT>( argc, argv );
}
else if ( GF2::console::find_switch(argc,argv,"--solver") || GF2::console::find_switch(argc,argv,"--solver3D") ) // Note: "solver", not "solve" :-S
{
return solve( argc, argv );
//return GF2::Solver::solve( argc, argv );
}
else if ( GF2::console::find_switch(argc,argv,"--datafit") || GF2::console::find_switch(argc,argv,"--datafit3D") )
{
return datafit( argc, argv );
//return GF2::Solver::datafit( argc, argv );
}
else if ( GF2::console::find_switch(argc,argv,"--merge") || GF2::console::find_switch(argc,argv,"--merge3D") )
{
return merge(argc, argv);
}
else if ( GF2::console::find_switch(argc,argv,"--show") )
{
std::cerr << "[" << __func__ << "]: " << "the show option has been moved to a separate executable, please use thatt one" << std::endl;
return 1;
//return GF2::Solver::show( argc, argv );
}
else if ( GF2::console::find_switch(argc,argv,"--subsample") )
{
return subsample( argc, argv );
}
// else if ( GF2::console::find_switch(argc,argv,"--corresp") || GF2::console::find_switch(argc,argv,"--corresp3D") )
// {
// return corresp( argc, argv );
// }
std::cerr << "[" << __func__ << "]: " << "unrecognized option" << std::endl;
return 1;
// --show --dir . --cloud cloud.ply --scale 0.05f --assoc points_primitives.txt --use-tags --no-clusters --prims primitives.bonmin.txt
// std::string img_path( "input2.png" );
// pcl::console::parse_argument( argc, argv, "--img", img_path );
// float scale = 0.1f;
// pcl::console::parse_argument( argc, argv, "--scale", scale );
// return GF2::Solver::run( img_path, scale, {0, M_PI_2, M_PI}, argc, argv );
}
开发者ID:NUAAXXY,项目名称:globOpt,代码行数:78,代码来源:qp_main.cpp
示例7: fopen
void SampleSAT::islearn(int datasize, char* outfilename)
{
int iteration = 0; // iteration counter
double drand; // double type random variable
int irand; // integer type random variable
double lik; // likelihood
double stSec1;
double stSec2;
double stSec3;
int step = 1; // length of Markov chain
cdsdSec = 0;
cdddSec = 0;
cntSec = 0;
double pF = 0;
double adlogmax;
double logsum;
int admaxidx;
double hl_ss;
double temp;
bool flag;
FILE* helFile = fopen(outfilename, "w");
while(iteration < lparams_->maxiter){
iteration++;
if(iteration == 1){
for(int j = 0; j < numAtom; j++){
sd[j] = 0;
}
}
stSec1 = timer.time();
///// sampling routine ////
for(int i = 0; i < lparams_->numsample; i++){
drand = sat_->getGrand()*datasize;
irand = drand; // get random integers in (0~datasize)
for(int j = 0; j < numAtom; j++){
xx[j] = tdata[irand][j];
} // get random one training data (one model)
for(int j = 0; j < step; j++){
solve(sat_, xx);
}
for(int j = 0; j < numAtom; j++){
sbuf[i][j] = xx[j];
}
for(int j = 0; j < numAtom; j++){
if(xx[j] == 1){
weight[i] += log(sat_->getTheta(j));
}else{
weight[i] += log(1-sat_->getTheta(j));
}
}
}
normalize(weight, lparams_->numsample);
for(int j = 0; j < numAtom; j++){
sd[j] += weight[j]*(xx[j])/(sat_->getTheta(j)) - weight[j]*(1 - xx[j])/(1 - sat_->getTheta(j));
} //sum sample counts
cdsdSec += timer.time() - stSec1;
/// calc. q(\x|F) from local samples ///
for(int j = 0; j < datasize_t; j++){
counts[j] = 0;
}
stSec3 = timer.time();
for(int i = 0; i < datasize_t; i++){
for(int j = 0; j < numAtom; j++){
if(sdata[i][j] == 1){
q_xF[i] += log(sat_->getRealProb(j));
}else{
q_xF[i] += log(1-sat_->getRealProb(j));
}
}
}
normalize(q_xF, datasize_t);
cntSec += timer.time() - stSec3;
stSec2 = timer.time();
for(int i = 0; i < datasize; i++){
for(int j = 0; j < numAtom; j++){
dd[j] += (tdata[i][j])/(sat_->getTheta(j)) - (1 - tdata[i][j])/(1 - sat_->getTheta(j));
}
} //calc dd
for(int j = 0; j < numAtom; j++){
dd[j] /= datasize;
}
cdddSec += timer.time() - stSec2;
for(int j = 0; j < numAtom; j++){
ex[j] = lparams_->ita*(dd[j] - sd[j]);
} // calc ex
sat_->updateTheta(ex); //update theta
pF=0;
logsum = 0;
adlogmax = -100000;
admaxidx = 0;
lik=0;
//.........这里部分代码省略.........
开发者ID:yamaguchimsf,项目名称:git,代码行数:101,代码来源:samplesat.cpp
示例8: PetscPrintf
//.........这里部分代码省略.........
prim->vars[var] = primOld->vars[var];
numReads += 1;
numWrites += 1;
}
af::timer inductionEqnTimer = af::timer::start();
cons->vars[vars::B1] =
consOld->vars[vars::B1] - 0.5*dt*divFluxes->vars[vars::B1];
cons->vars[vars::B2] =
consOld->vars[vars::B2] - 0.5*dt*divFluxes->vars[vars::B2];
cons->vars[vars::B3] =
consOld->vars[vars::B3] - 0.5*dt*divFluxes->vars[vars::B3];
prim->vars[vars::B1] = cons->vars[vars::B1]/geomCenter->g;
prim->vars[vars::B1].eval();
prim->vars[vars::B2] = cons->vars[vars::B2]/geomCenter->g;
prim->vars[vars::B2].eval();
prim->vars[vars::B3] = cons->vars[vars::B3]/geomCenter->g;
prim->vars[vars::B3].eval();
double inductionEqnTime = af::timer::stop(inductionEqnTimer);
primGuessPlusEps->vars[vars::B1] = prim->vars[vars::B1];
primGuessPlusEps->vars[vars::B2] = prim->vars[vars::B2];
primGuessPlusEps->vars[vars::B3] = prim->vars[vars::B3];
primGuessLineSearchTrial->vars[vars::B1] = prim->vars[vars::B1];
primGuessLineSearchTrial->vars[vars::B2] = prim->vars[vars::B2];
primGuessLineSearchTrial->vars[vars::B3] = prim->vars[vars::B3];
/* Solve dU/dt + div.F - S = 0 to get prim at n+1/2 */
jacobianAssemblyTime = 0.;
lineSearchTime = 0.;
linearSolverTime = 0.;
af::timer solverTimer = af::timer::start();
solve(*prim);
double solverTime = af::timer::stop(solverTimer);
/* Copy solution to primHalfStepGhosted. WARNING: Right now
* primHalfStep->vars[var] points to prim->vars[var]. Might need to do a deep
* copy. */
for (int var=0; var < prim->numVars; var++)
{
primHalfStep->vars[var] = prim->vars[var];
numReads += 1;
numWrites += 1;
}
af::timer halfStepCommTimer = af::timer::start();
primHalfStep->communicate();
double halfStepCommTime = af::timer::stop(halfStepCommTimer);
af::timer halfStepDiagTimer = af::timer::start();
halfStepDiagnostics(numReads,numWrites);
double halfStepDiagTime = af::timer::stop(halfStepDiagTimer);
/* Half step complete */
double halfStepTime = af::timer::stop(halfStepTimer);
PetscPrintf(PETSC_COMM_WORLD, "\n");
PetscPrintf(PETSC_COMM_WORLD, " ---Performance report--- \n");
PetscPrintf(PETSC_COMM_WORLD, " Boundary Conditions : %g secs, %g %\n",
boundaryTime, boundaryTime/halfStepTime * 100
);
PetscPrintf(PETSC_COMM_WORLD, " Setting elemOld : %g secs, %g %\n",
elemOldTime,
elemOldTime/halfStepTime * 100
);
开发者ID:AFD-Illinois,项目名称:grim,代码行数:67,代码来源:timestep.cpp
示例9: CV_Assert
cv::RotatedRect cv::fitEllipse( InputArray _points )
{
Mat points = _points.getMat();
int i, n = points.checkVector(2);
int depth = points.depth();
CV_Assert( n >= 0 && (depth == CV_32F || depth == CV_32S));
RotatedRect box;
if( n < 5 )
CV_Error( CV_StsBadSize, "There should be at least 5 points to fit the ellipse" );
// New fitellipse algorithm, contributed by Dr. Daniel Weiss
Point2f c(0,0);
double gfp[5], rp[5], t;
const double min_eps = 1e-8;
bool is_float = depth == CV_32F;
const Point* ptsi = points.ptr<Point>();
const Point2f* ptsf = points.ptr<Point2f>();
AutoBuffer<double> _Ad(n*5), _bd(n);
double *Ad = _Ad, *bd = _bd;
// first fit for parameters A - E
Mat A( n, 5, CV_64F, Ad );
Mat b( n, 1, CV_64F, bd );
Mat x( 5, 1, CV_64F, gfp );
for( i = 0; i < n; i++ )
{
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
c += p;
}
c.x /= n;
c.y /= n;
for( i = 0; i < n; i++ )
{
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
p -= c;
bd[i] = 10000.0; // 1.0?
Ad[i*5] = -(double)p.x * p.x; // A - C signs inverted as proposed by APP
Ad[i*5 + 1] = -(double)p.y * p.y;
Ad[i*5 + 2] = -(double)p.x * p.y;
Ad[i*5 + 3] = p.x;
Ad[i*5 + 4] = p.y;
}
solve(A, b, x, DECOMP_SVD);
// now use general-form parameters A - E to find the ellipse center:
// differentiate general form wrt x/y to get two equations for cx and cy
A = Mat( 2, 2, CV_64F, Ad );
b = Mat( 2, 1, CV_64F, bd );
x = Mat( 2, 1, CV_64F, rp );
Ad[0] = 2 * gfp[0];
Ad[1] = Ad[2] = gfp[2];
Ad[3] = 2 * gfp[1];
bd[0] = gfp[3];
bd[1] = gfp[4];
solve( A, b, x, DECOMP_SVD );
// re-fit for parameters A - C with those center coordinates
A = Mat( n, 3, CV_64F, Ad );
b = Mat( n, 1, CV_64F, bd );
x = Mat( 3, 1, CV_64F, gfp );
for( i = 0; i < n; i++ )
{
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
p -= c;
bd[i] = 1.0;
Ad[i * 3] = (p.x - rp[0]) * (p.x - rp[0]);
Ad[i * 3 + 1] = (p.y - rp[1]) * (p.y - rp[1]);
Ad[i * 3 + 2] = (p.x - rp[0]) * (p.y - rp[1]);
}
solve(A, b, x, DECOMP_SVD);
// store angle and radii
rp[4] = -0.5 * atan2(gfp[2], gfp[1] - gfp[0]); // convert from APP angle usage
if( fabs(gfp[2]) > min_eps )
t = gfp[2]/sin(-2.0 * rp[4]);
else // ellipse is rotated by an integer multiple of pi/2
t = gfp[1] - gfp[0];
rp[2] = fabs(gfp[0] + gfp[1] - t);
if( rp[2] > min_eps )
rp[2] = std::sqrt(2.0 / rp[2]);
rp[3] = fabs(gfp[0] + gfp[1] + t);
if( rp[3] > min_eps )
rp[3] = std::sqrt(2.0 / rp[3]);
box.center.x = (float)rp[0] + c.x;
box.center.y = (float)rp[1] + c.y;
box.size.width = (float)(rp[2]*2);
box.size.height = (float)(rp[3]*2);
if( box.size.width > box.size.height )
{
float tmp;
CV_SWAP( box.size.width, box.size.height, tmp );
box.angle = (float)(90 + rp[4]*180/CV_PI);
//.........这里部分代码省略.........
开发者ID:007Indian,项目名称:opencv,代码行数:101,代码来源:shapedescr.cpp
示例10: main
int main(){
scanf("%d %d", &N, &M);
solve();
return 0;
}
开发者ID:shenzhu,项目名称:Algorithms,代码行数:5,代码来源:ShortestMazePath.cpp
示例11: main
开发者ID:hardrock12,项目名称:competetive-uva,代码行数:6,代码来源:10583.cpp
示例12: main
/* entry point */
int main(int argc, char** argv){
solve();
return 0;
}
开发者ID:Mb01,项目名称:programming_challenges,代码行数:5,代码来源:amidakuji.c
示例13: solve
ompl::base::PlannerStatus ompl::tools::Lightning::solve(double time)
{
ob::PlannerTerminationCondition ptc = ob::timedPlannerTerminationCondition(time);
return solve(ptc);
}
开发者ID:HRZaheri,项目名称:batch-informed-trees,代码行数:5,代码来源:Lightning.cpp
示例14: depthSum
int depthSum(std::vector<NestedInteger>& V) {
return solve(V, 1);
}
开发者ID:iamslash,项目名称:learn_to_code,代码行数:3,代码来源:a.cpp
示例15: main
int main () {
int p;
scanf("%d", &p);
printf("%d\n", solve(p));
return 0;
}
开发者ID:NorfairKing,项目名称:project-euler,代码行数:6,代码来源:solution.c
示例16: full_solve
int
full_solve (hid_t fid, hid_t dataset, hid_t* routeDatasets, hid_t dataspace, hid_t routeDataspace, hid_t datatype, hid_t routeDatatype, int cell_index, const inp_t * input_params, SOURCE_MODE mode,
const cell_table_t * cell, const net_t * network, const time_steps_t * ts,
int verbose)
{
double *abundances = NULL;
alloc_abundances( network, &abundances ); // Allocate the abundances array; it contains all species.
rout_t* routes = NULL;
if (( routes =
malloc (sizeof (rout_t) * input_params->output.n_output_species * N_OUTPUT_ROUTES)) == NULL)
{
fprintf (stderr, "astrochem: %s:%d: routes allocation failed.\n",
__FILE__, __LINE__);
return EXIT_SUCCESS;
}
double* output_abundances = NULL;
if (( output_abundances =
malloc (sizeof (double) * input_params->output.n_output_species )) == NULL)
{
fprintf (stderr, "astrochem: %s:%d: array allocation failed.\n",
__FILE__, __LINE__);
return EXIT_FAILURE;
}
#ifdef HAVE_OPENMP
omp_set_lock(&lock);
#endif
// Create the memory dataspace, selecting all output abundances
hsize_t size = input_params->output.n_output_species;
hid_t memDataspace = H5Screate_simple(1, &size, NULL);
// Create the file dataspace, and prepare selection of a chunk of the file
hid_t fileDataspace = H5Scopy(dataspace);
hsize_t count[3]={ 1, 1, input_params->output.n_output_species };
hsize_t routeSize[2] = { input_params->output.n_output_species, N_OUTPUT_ROUTES };
hsize_t routeCount[4]={ 1, 1, input_params->output.n_output_species, N_OUTPUT_ROUTES };
hid_t routeFileDataspace, routeMemDataspace;
if (input_params->output.trace_routes)
{
// Create the route memory dataspace, selecting all output routes
routeMemDataspace = H5Screate_simple(2, routeSize, NULL);
// Create the route file dataspace, and prepare selection of a chunk of the file
routeFileDataspace = H5Scopy(routeDataspace);
}
#ifdef HAVE_OPENMP
omp_unset_lock(&lock);
#endif
// Initializing abundance
#if 0 //Ultra complicated code
const species_name_t* species = malloc( input_params->abundances.n_initial_abundances * sizeof(*species));
double *initial_abundances = malloc( input_params->abundances.n_initial_abundances * sizeof(double) );
int i;
for( i = 0; i < input_params->abundances.n_initial_abundances ; i++ )
{
strcpy( network->species_names[input_params->abundances.initial_abundances[i].species_idx ] , species[i] );
initial_abundances[i] = input_params->abundances.initial_abundances[i].abundance;
}
set_initial_abundances( species, 3, initial_abundances, &network, abundances); // Set initial abundances
#else // same thing , without using api
int i;
for( i = 0; i < input_params->abundances.n_initial_abundances ; i++ )
{
abundances[ input_params->abundances.initial_abundances[i].species_idx ] = input_params->abundances.initial_abundances[i].abundance;
}
// Add grain abundances
int g, gm, gp;
double gabs;
g = find_species ("grain", network);
gm = find_species ("grain(-)", network);
gp = find_species ("grain(+)", network);
// Check if grain abundances have already been initialized one way or another
gabs=0.0;
if(g>=0) gabs += abundances[ g ];
if(gm>=0) gabs += abundances[ gm ];
if(gp>=0) gabs += abundances[ gp ];
if(gabs == 0.0) {
// Grains have not been initialized
// Check that grains are defined in our network, and if so, set the grain abundance
if(g>=0)
abundances[ g ] = input_params->phys.grain_abundance;
}
#endif
double min_nh; /* Minimum density */
/* Compute the minimum density to set the absolute tolerance of the
//.........这里部分代码省略.........
开发者ID:glesur,项目名称:astrochem,代码行数:101,代码来源:astrochem.c
示例17: main
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
// create cfdemCloud
#include "readGravitationalAcceleration.H"
cfdemCloud particleCloud(mesh);
#include "checkModelType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "readPISOControls.H"
#include "CourantNo.H"
// do particle stuff
Info << "- evolve()" << endl;
particleCloud.evolve(voidfraction,Us,U);
Ksl.internalField() = particleCloud.momCoupleM(0).impMomSource();
Ksl.correctBoundaryConditions();
#include "solverDebugInfo.H"
// get scalar source from DEM
particleCloud.forceM(1).manipulateScalarField(Tsource);
Tsource.correctBoundaryConditions();
// solve scalar transport equation
phi = fvc::interpolate(U*voidfraction) & mesh.Sf();
solve
(
fvm::ddt(voidfraction,T)
+ fvm::div(phi, T)
- fvm::laplacian(DT*voidfraction, T)
==
Tsource
);
// Pressure-velocity PISO corrector
{
// Momentum predictor
fvVectorMatrix UEqn
(
fvm::ddt(voidfraction,U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
- fvm::Sp(Ksl/rho,U)
);
UEqn.relax();
if (momentumPredictor)
{
//solve UEqn
if (modelType=="B")
solve(UEqn == - fvc::grad(p) + Ksl/rho*Us);
else
solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us);
}
// --- PISO loop
//for (int corr=0; corr<nCorr; corr++)
int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1);
for (int corr=0; corr<nCorrSoph; corr++)
{
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA));
U = rUA*UEqn.H();
phi = fvc::interpolate(U*voidfraction) & mesh.Sf();
//+ fvc::ddtPhiCorr(rUA, U, phi)
surfaceScalarField phiS(fvc::interpolate(Us*voidfraction) & mesh.Sf());
surfaceScalarField phiGes = phi + rUAf*(fvc::interpolate(Ksl/rho) * phiS);
volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction);
if (modelType=="A")
rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction);
// Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
// Pressure corrector
fvScalarMatrix pEqn
(
fvm::laplacian(rUAvoidfraction, p) == fvc::div(phiGes) + fvc::ddt(voidfraction)
//.........这里部分代码省略.........
开发者ID:wangxiaoliang2012,项目名称:CFDEMcoupling-PUBLIC,代码行数:101,代码来源:cfdemSolverPisoScalar.C
示例18: main
int main() {
solve();
return 0;
}
开发者ID:nozdrenkov,项目名称:sp,代码行数:6,代码来源:3.cpp
示例19: picosecFromStart
size_t FieldStatic::solveRows() {
size_t maxIterationsCount = 0;
auto solveStart = picosecFromStart();
if (transposed) {
if (algo::ftr().Balancing()) {
--balancingCounter;
if (balancingCounter == 0) {
shouldSendWeights = true;
balancingCounter = (int)algo::ftr().TransposeBalanceIterationsInterval();
}
}
resetCalculatingRows();
bool first = true;
if (myCoord == 0) {
balanceBundleSize();
}
bool solving = true;
while (solving) {
size_t fromFirstPassRow = 0;
size_t fromSecondPassRow = 0;
while (fromSecondPassRow < height) {
size_t nextSecondPassRow = 0;
if (fromSecondPassRow < height && fromFirstPassRow > fromSecondPassRow) {
nextSecondPassRow = secondPasses(fromSecondPassRow, first, true);
}
size_t nextFirstPassRow = 0;
if (fromFirstPassRow < height) {
nextFirstPassRow = firstPasses(fromFirstPassRow, first, true);
}
if (nextFirstPassRow == 0 && nextSecondPassRow == 0) {
if (fromFirstPassRow < height) {
nextFirstPassRow = firstPasses(fromFirstPassRow, first, false);
}
else {
nextSecondPassRow = secondPasses(fromSecondPassRow, first, false);
}
}
if (nextFirstPassRow > 0) {
if (nextFirstPassRow == height * 2) {
solving = false;
break;
}
fromFirstPassRow = nextFirstPassRow;
}
if (nextSecondPassRow > 0) {
fromSecondPassRow = nextSecondPassRow;
}
}
if (solving == false) {
break;
}
first = false;
std::swap(nextCalculatingRows, calculatingRows);
++maxIterationsCount;
if (maxIterationsCount >= MAX_ITTERATIONS_COUNT) {
break;
}
if (leftN == NOBODY) {
solving = false;
for (size_t row = 0; row < height; ++row) {
if (calculatingRows[row]) {
solving = true;
break;
}
}
if (solving == false) {
sendDoneAsFirstPass();
}
}
}
}
else {
if (shouldBalanceNext) {
balance();
shouldBalanceNext = false;
}
size_t firstRealRow = (topN == NOBODY ? 0 : 1);
size_t lastRealRow = height - firstRealRow - (bottomN ? 0 : 1);
for (size_t row = 0; row < height; ++row) {
fillFactors(row, true);
double delta = solve(row, true);
size_t iterationsCount = 1;
auto startTime = picosecFromStart();
while (delta > epsilon) {
fillFactors(row, false);
//.........这里部分代码省略.........
开发者ID:bamx23,项目名称:diploma,代码行数:101,代码来源:field-static.cpp
示例20: main
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
pimpleControl pimple(mesh);
#include "createFields.H"
#include "readTimeControls.H"
bool checkMeshCourantNo =
readBool(pimple.dict().lookup("checkMeshCourantNo"));
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "initContinuityErrs.H"
#include "readCourantType.H"
dimensionedScalar v_zero("v_zero", dimVolume/dimTime, 0.0);
Info<< "\nStarting time loop\n" << endl;
#include "createSurfaceFields.H"
#include "markBadQualityCells.H"
while (runTime.run())
{
#include "acousticCourantNo.H"
#include "compressibleCourantNo.H"
#include "readTimeControls.H"
#include "setDeltaT.H"
runTime++;
psi.oldTime();
rho.oldTime();
p.oldTime();
U.oldTime();
h.oldTime();
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Move mesh and update fluxes
{
// Do any mesh changes
mesh.update();
if (mesh.changing())
{
if (runTime.timeIndex() > 1)
{
surfaceScalarField amNew = min(min(phiv_pos - fvc::meshPhi(rho,U) - cSf_pos, phiv_neg - fvc::meshPhi(rho,U) - cSf_neg), v_zero);
phiNeg += kappa*(amNew - am)*p_neg*psi_neg;
phiPos += (1.0 - kappa)*(amNew - am)*p_neg*psi_neg;
}
else
{
phiNeg -= fvc::meshPhi(rho,U) * fvc::interpolate(rho);
}
phi = phiPos + phiNeg;
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
#include "markBadQualityCells.H"
}
}
// --- Solve density
solve
(
fvm::ddt(rho) + fvc::div(phi)
);
Info<< "rho max/min : " << max(rho).value()
<< " " << min(rho).value() << endl;
// --- Solve momentum
#include "UEqn.H"
// --- Solve energy
#include "hEqn.H"
// --- Solve pressure (PISO)
{
while (pimple.correct())
{
#include "pEqnDyM.H"
}
#include "updateKappa.H"
}
// --- Solve turbulence
turbulence->correct();
Ek = 0.5*magSqr(U);
EkChange = fvc::ddt(rho,Ek) + fvc::div(phiPos,Ek) + fvc::div(phiNeg,Ek);
//.........这里部分代码省略.........
开发者ID:unicfdlab,项目名称:pisoCentralFoam,代码行数:101,代码来源:pisoCentralDyMFoam.C
注:本文中的solve函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论