本文整理汇总了C++中fsi::vector类的典型用法代码示例。如果您正苦于以下问题:C++ vector类的具体用法?C++ vector怎么用?C++ vector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSourceTerm
void ESDIRK::getSourceTerm(
const bool /*corrector*/,
const int k,
const int /*sweep*/,
const scalar deltaT,
fsi::vector & rhs,
fsi::vector & qold
)
{
assert( k <= nbStages - 1 );
qold = this->qold;
// Compute the time step from the stage deltaT
if ( dt < 0 )
{
// first time step, first prediction step
dt = deltaT / A( k, k );
}
assert( dt > 0 );
rhs.setZero();
// Calculate sum of the stage residuals
for ( int iStage = 0; iStage < k; iStage++ )
rhs += A( k, iStage ) * F.row( iStage ).transpose();
rhs.array() *= dt;
this->stageIndex = k;
}
示例2: optimize
void ImplicitMultiLevelFsiSolver::optimize(
const fsi::vector & y,
const fsi::vector & x0,
fsi::vector & xk
)
{
assert( init );
assert( y.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| y.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( x0.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| x0.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( xk.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| xk.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( x0.rows() == xk.rows() );
assert( y.rows() == xk.rows() );
fsi->newMeasurementSeries();
postProcessing->performPostProcessing( y, x0, xk );
}
示例3: storeFunction
void DataStorage::storeFunction(
const fsi::vector & f,
int substep
)
{
assert( f.rows() == F.cols() );
assert( substep <= F.rows() );
assert( not std::isnan( f.norm() ) );
F.row( substep ) = f;
}
示例4: storeSolution
void DataStorage::storeSolution(
const fsi::vector & sol,
int substep
)
{
assert( sol.rows() == solStages.cols() );
assert( substep <= solStages.rows() );
assert( not std::isnan( sol.norm() ) );
solStages.row( substep ) = sol;
}
示例5: evaluate
void ImplicitMultiLevelFsiSolver::evaluate(
const fsi::vector & x,
fsi::vector & output,
fsi::vector & R
)
{
assert( init );
assert( x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( output.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| output.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( R.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
|| R.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
+ fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );
assert( x.rows() == output.rows() );
assert( x.rows() == R.rows() );
fsi->evaluate( x, output, R );
}
示例6: optimize
virtual void optimize(
const fsi::vector & y,
const fsi::vector & /*x0*/,
fsi::vector & xk
)
{
assert( y.rows() == 3 );
assert( xk.rows() == 2 );
// Analytical optimum
xk( 0 ) = (y[2] - y[0]) / 2.0;
xk( 1 ) = (y[0] + y[1] + y[2]) / 3.0;
}
示例7: solFluid
void SDCFsiSolver::setSolution(
const fsi::vector & solution,
const fsi::vector & f
)
{
Eigen::Map<const fsi::vector> solFluid( solution.data(), dofFluid );
Eigen::Map<const fsi::vector> solSolid( solution.data() + dofFluid, dofSolid );
Eigen::Map<const fsi::vector> fFluid( f.data(), dofFluid );
Eigen::Map<const fsi::vector> fSolid( f.data() + dofFluid, dofSolid );
fluid->setSolution( solFluid, fFluid );
solid->setSolution( solSolid, fSolid );
}
示例8: evaluate
virtual void evaluate(
const fsi::vector & x,
fsi::vector & output,
fsi::vector & R
)
{
assert( x.rows() == 2 );
assert( R.rows() == 3 );
fsi::vector t( 3 );
t << -1, 0, 1;
R = x( 0 ) * t + x( 1 ) * Eigen::MatrixXd::Ones( 3, 1 );
output = R;
}
示例9: isConvergence
virtual bool isConvergence(
const fsi::vector & x,
const fsi::vector & xprev
)
{
assert( x.rows() == xprev.rows() );
iter++;
allConverged_ = false;
if ( (x - xprev).norm() < tol * x.norm() )
allConverged_ = true;
return allConverged_;
}
示例10: qoldFluid
void SDCFsiSolver::implicitSolve(
bool corrector,
const int k,
const int kold,
const scalar t,
const scalar dt,
const fsi::vector & qold,
const fsi::vector & rhs,
fsi::vector & f,
fsi::vector & result
)
{
Eigen::Map<const fsi::vector> qoldFluid( qold.data(), dofFluid );
Eigen::Map<const fsi::vector> qoldSolid( qold.data() + dofFluid, dofSolid );
Eigen::Map<const fsi::vector> rhsFluid( rhs.data(), dofFluid );
Eigen::Map<const fsi::vector> rhsSolid( rhs.data() + dofFluid, dofSolid );
fluid->prepareImplicitSolve( corrector, k, kold, t, dt, qoldFluid, rhsFluid );
solid->prepareImplicitSolve( corrector, k, kold, t, dt, qoldSolid, rhsSolid );
// Perform FSI iterations to solve the coupled problem
postProcessing->fsi->newMeasurementSeries();
// Initial solution
fsi::vector x0;
if ( corrector )
x0 = xStages.at( k + 1 );
else
x0 = xStages.at( k );
postProcessing->initStage( k );
postProcessing->performPostProcessing( x0, postProcessing->fsi->x );
postProcessing->finalizeStage();
getSolution( result, f );
evaluateFunction( k, result, t, f );
xStages.at( k + 1 ) = postProcessing->fsi->x;
fluid->finalizeImplicitSolve( k );
solid->finalizeImplicitSolve( k );
}
示例11: fFluid
void SDCFsiSolver::evaluateFunction(
const int k,
const fsi::vector & q,
const scalar t,
fsi::vector & f
)
{
fsi::vector fFluid( dofFluid ), fSolid( dofSolid );
Eigen::Map<const fsi::vector> qFluid( q.data(), dofFluid );
Eigen::Map<const fsi::vector> qSolid( q.data() + dofFluid, dofSolid );
fluid->evaluateFunction( k, qFluid, t, fFluid );
solid->evaluateFunction( k, qSolid, t, fSolid );
f.head( dofFluid ) = fFluid;
f.tail( dofSolid ) = fSolid;
}
示例12: setFunction
void ESDIRK::setFunction(
const int k,
const fsi::vector & f,
const fsi::vector & result
)
{
assert( f.rows() == result.rows() );
assert( k <= nbStages - 1 );
if ( F.cols() == 0 )
F.resize( nbStages, f.rows() );
if ( solStages.cols() == 0 )
solStages.resize( nbStages, f.rows() );
F.row( k ) = f;
solStages.row( k ) = result;
}
示例13: b
void TubeFlowLinearizedFluidSolver::solve(
const fsi::vector & a,
fsi::vector & p
)
{
this->a = a.array() - a0;
std::cout << "Solve fluid domain" << std::endl;
// Construct right hand size of linear system
fsi::vector b( 2 * N ), x( 2 * N );
b.setZero();
for ( int i = 1; i < N - 1; i++ )
{
// Continuity equation rhs
b( i ) = dx / dt * ( an( i ) - this->a( i ) );
b( i ) += 0.5 * u0 * ( this->a( i - 1 ) - this->a( i + 1 ) );
// Momentum equation rhs
b( i + N ) = u0 * dx / dt * ( an( i ) - this->a( i ) );
b( i + N ) += 0.5 * u0 * u0 * ( this->a( i - 1 ) - this->a( i + 1 ) );
b( i + N ) += a0 * dx / dt * un( i );
}
// Boundary conditions
// Velocity inlet condition
b( 0 ) = u0 / 10.0 * std::pow( std::sin( M_PI * timeIndex * tau ), 2 );
// Pressure inlet
b( N ) = 0;
// Velocity outlet condition
b( N - 1 ) = 0;
// Pressure outlet condition
b( 2 * N - 1 ) = -cmk * rho * un( N - 1 ) + pn( N - 1 );
// Solve for x
x = lu.solve( b );
// Retrieve solution
u = x.head( N );
this->p = x.tail( N );
// Return pressure p
p = this->p.array() + p0;
data.col( 0 ) = p;
}
示例14: operator
int operator()(
const fsi::vector & x,
fsi::vector & fvec
) const
{
fsi::vector output( x.rows() );
model->evaluate( x, output, fvec );
fvec -= *y;
return 0;
}
示例15: setOldSolution
void ESDIRK::setOldSolution(
int timeIndex,
const fsi::vector & result
)
{
assert( timeIndex >= this->timeIndex );
if ( qold.rows() == result.rows() )
qold = solStages.bottomRows( 1 ).transpose();
else
if ( timeIndex > this->timeIndex )
qold = result;
this->timeIndex = timeIndex;
}