本文整理汇总了C++中AssemblyOptions类的典型用法代码示例。如果您正苦于以下问题:C++ AssemblyOptions类的具体用法?C++ AssemblyOptions怎么用?C++ AssemblyOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssemblyOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(symmetric_matches_nonsymmetric_in_aca_mode,
ValueType, result_types)
{
typedef ValueType RT;
typedef typename Fiber::ScalarTraits<ValueType>::RealType RealType;
typedef RealType BFT;
if (boost::is_same<RT, std::complex<float> >::value) {
// The AHMED support for single-precision complex symmetric matrices
// is broken
BOOST_CHECK(true);
return;
}
GridParameters params;
params.topology = GridParameters::TRIANGULAR;
shared_ptr<Grid> grid = GridFactory::importGmshGrid(
params, "../../examples/meshes/sphere-h-0.4.msh",
false /* verbose */);
PiecewiseLinearContinuousScalarSpace<BFT> pwiseLinears(grid);
PiecewiseConstantScalarSpace<BFT> pwiseConstants(grid);
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
AcaOptions acaOptions;
acaOptions.minimumBlockSize = 4;
assemblyOptions.switchToAcaMode(acaOptions);
AccuracyOptions accuracyOptions;
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(4);
accuracyOptions.doubleSingular.setRelativeQuadratureOrder(2);
NumericalQuadratureStrategy<BFT, RT> quadStrategy(accuracyOptions);
Context<BFT, RT> context(make_shared_from_ref(quadStrategy), assemblyOptions);
const RT waveNumber = initWaveNumber<RT>();
BoundaryOperator<BFT, RT> opNonsymmetric =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
make_shared_from_ref(context),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseConstants),
make_shared_from_ref(pwiseLinears),
waveNumber,
"", NO_SYMMETRY);
BoundaryOperator<BFT, RT> opSymmetric =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
make_shared_from_ref(context),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseConstants),
make_shared_from_ref(pwiseLinears),
waveNumber,
"", SYMMETRIC);
arma::Mat<RT> matNonsymmetric = opNonsymmetric.weakForm()->asMatrix();
arma::Mat<RT> matSymmetric = opSymmetric.weakForm()->asMatrix();
BOOST_CHECK(check_arrays_are_close<RT>(
matNonsymmetric, matSymmetric, 2 * acaOptions.eps));
}
开发者ID:huidong80,项目名称:bempp,代码行数:60,代码来源:test_modified_helmholtz_3d_single_layer_boundary_operator.cpp
示例2: DefaultLocalAssemblerForIntegralOperatorsOnSurfacesManager
DefaultLocalAssemblerForIntegralOperatorsOnSurfacesManager(
bool cacheSingularIntegrals)
{
// Create a Bempp grid
shared_ptr<Grid> grid = createGrid();
// These important thing is that the domain and dualToRange spaces are
// different
piecewiseConstantSpace = std::auto_ptr<PiecewiseConstantSpace>(
new PiecewiseConstantSpace(grid));
piecewiseLinearSpace = std::auto_ptr<PiecewiseLinearSpace>(
new PiecewiseLinearSpace(grid));
op = std::auto_ptr<Operator>(new Operator(
make_shared_from_ref(*piecewiseConstantSpace),
make_shared_from_ref(*piecewiseLinearSpace),
make_shared_from_ref(*piecewiseLinearSpace),
"SLP"));
// Construct local assembler
Fiber::AccuracyOptions options;
options.doubleRegular.setRelativeQuadratureOrder(1);
quadStrategy = std::auto_ptr<QuadratureStrategy>(new QuadratureStrategy);
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
assemblyOptions.enableSingularIntegralCaching(cacheSingularIntegrals);
assembler = op->makeAssembler(*quadStrategy, assemblyOptions);
}
开发者ID:UCL,项目名称:bempp,代码行数:30,代码来源:test_default_local_assembler_for_integral_operators_on_surfaces.cpp
示例3: BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(L2Norm_works_for_constant_function_and_piecewise_constants, ResultType, result_types)
{
typedef ResultType RT;
typedef typename ScalarTraits<RT>::RealType BFT;
typedef typename ScalarTraits<RT>::RealType CT;
GridParameters params;
params.topology = GridParameters::TRIANGULAR;
shared_ptr<Grid> grid = GridFactory::importGmshGrid(
params, "../../meshes/sphere-h-0.1.msh", false /* verbose */);
shared_ptr<Space<BFT> > space(
new PiecewiseConstantScalarSpace<BFT>(grid));
AccuracyOptions accuracyOptions;
shared_ptr<NumericalQuadratureStrategy<BFT, RT> > quadStrategy(
new NumericalQuadratureStrategy<BFT, RT>(accuracyOptions));
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
shared_ptr<Context<BFT, RT> > context(
new Context<BFT, RT>(quadStrategy, assemblyOptions));
Bempp::GridFunction<BFT, RT> fun(context, space, space,
surfaceNormalIndependentFunction(
ConstantFunction<RT>()));
CT norm = fun.L2Norm();
CT expectedNorm = sqrt(2. * 2. * 4. * M_PI);
BOOST_CHECK_CLOSE(norm, expectedNorm, 1 /* percent */);
}
示例4: BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(cubic_function_can_be_expanded_in_cubic_space, ResultType, result_types)
{
typedef ResultType RT;
typedef typename ScalarTraits<RT>::RealType BFT;
typedef typename ScalarTraits<RT>::RealType CT;
GridParameters params;
params.topology = GridParameters::TRIANGULAR;
shared_ptr<Grid> grid = GridFactory::importGmshGrid(
params, "../../examples/meshes/sphere-h-0.2.msh", false /* verbose */);
shared_ptr<Space<BFT> > space(
new PiecewisePolynomialDiscontinuousScalarSpace<BFT>(grid, 3));
AccuracyOptions accuracyOptions;
accuracyOptions.singleRegular.setRelativeQuadratureOrder(2);
shared_ptr<NumericalQuadratureStrategy<BFT, RT> > quadStrategy(
new NumericalQuadratureStrategy<BFT, RT>(accuracyOptions));
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
shared_ptr<Context<BFT, RT> > context(
new Context<BFT, RT>(quadStrategy, assemblyOptions));
GridFunction<BFT, RT> function(
context, space, space,
surfaceNormalIndependentFunction(CubicFunction<RT>()));
CT absoluteError, relativeError;
estimateL2Error(
function, surfaceNormalIndependentFunction(CubicFunction<RT>()),
*quadStrategy, absoluteError, relativeError);
BOOST_CHECK_SMALL(relativeError, 1000 * std::numeric_limits<CT>::epsilon() /* percent */);
}
示例5: shouldUseBlasInQuadrature
inline bool shouldUseBlasInQuadrature(const AssemblyOptions& assemblyOptions,
const Space<BasisFunctionType>& domain,
const Space<BasisFunctionType>& dualToRange)
{
return assemblyOptions.isBlasEnabledInQuadrature() == AssemblyOptions::YES ||
(assemblyOptions.isBlasEnabledInQuadrature() == AssemblyOptions::AUTO &&
(maximumShapesetOrder(domain) >= 2 ||
maximumShapesetOrder(dualToRange) >= 2));
}
示例6: BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(aca_of_synthetic_maxwell_single_layer_operator_agrees_with_dense_assembly_in_asymmetric_case,
ValueType, complex_result_types)
{
typedef ValueType RT;
typedef typename ScalarTraits<ValueType>::RealType RealType;
typedef RealType BFT;
GridParameters params;
params.topology = GridParameters::TRIANGULAR;
shared_ptr<Grid> grid = GridFactory::importGmshGrid(
params, "../../meshes/sphere-h-0.4.msh", false /* verbose */);
RT waveNumber = initWaveNumber<RT>();
shared_ptr<Space<BFT> > vectorPwiseLinears(
new RaviartThomas0VectorSpace<BFT>(grid));
shared_ptr<Space<BFT> > vectorPwiseLinears2(
new RaviartThomas0VectorSpace<BFT>(grid));
AccuracyOptions accuracyOptions;
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2);
accuracyOptions.singleRegular.setRelativeQuadratureOrder(2);
shared_ptr<NumericalQuadratureStrategy<BFT, RT> > quadStrategy(
new NumericalQuadratureStrategy<BFT, RT>(accuracyOptions));
AssemblyOptions assemblyOptionsDense;
assemblyOptionsDense.setVerbosityLevel(VerbosityLevel::LOW);
shared_ptr<Context<BFT, RT> > contextDense(
new Context<BFT, RT>(quadStrategy, assemblyOptionsDense));
BoundaryOperator<BFT, RT> opDense =
maxwell3dSingleLayerBoundaryOperator<BFT>(
contextDense,
vectorPwiseLinears, vectorPwiseLinears, vectorPwiseLinears,
waveNumber);
arma::Mat<RT> weakFormDense = opDense.weakForm()->asMatrix();
AssemblyOptions assemblyOptionsAca;
assemblyOptionsAca.setVerbosityLevel(VerbosityLevel::LOW);
AcaOptions acaOptions;
acaOptions.mode = AcaOptions::LOCAL_ASSEMBLY;
assemblyOptionsAca.switchToAcaMode(acaOptions);
shared_ptr<Context<BFT, RT> > contextAca(
new Context<BFT, RT>(quadStrategy, assemblyOptionsAca));
// Internal domain different from dualToRange
BoundaryOperator<BFT, RT> opAca =
maxwell3dSingleLayerBoundaryOperator<BFT>(
contextAca,
vectorPwiseLinears, vectorPwiseLinears, vectorPwiseLinears2,
waveNumber);
arma::Mat<RT> weakFormAca = opAca.weakForm()->asMatrix();
BOOST_CHECK(check_arrays_are_close<ValueType>(
weakFormDense, weakFormAca, 2. * acaOptions.eps));
}
示例7: BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(interpolated_matches_noniterpolated,
BasisFunctionType, basis_function_types)
{
typedef BasisFunctionType BFT;
typedef typename Fiber::ScalarTraits<BFT>::ComplexType RT;
typedef typename Fiber::ScalarTraits<BFT>::ComplexType KT;
typedef typename Fiber::ScalarTraits<BFT>::RealType CT;
GridParameters params;
params.topology = GridParameters::TRIANGULAR;
shared_ptr<Grid> grid = GridFactory::importGmshGrid(
params, "meshes/two_disjoint_triangles.msh",
false /* verbose */);
PiecewiseLinearContinuousScalarSpace<BFT> pwiseLinears(grid);
PiecewiseConstantScalarSpace<BFT> pwiseConstants(grid);
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
AccuracyOptions accuracyOptions;
accuracyOptions.doubleRegular.setAbsoluteQuadratureOrder(5);
accuracyOptions.doubleSingular.setAbsoluteQuadratureOrder(5);
NumericalQuadratureStrategy<BFT, RT> quadStrategy(accuracyOptions);
Context<BFT, RT> context(make_shared_from_ref(quadStrategy), assemblyOptions);
const KT waveNumber(3.23, 0.31);
BoundaryOperator<BFT, RT> opNoninterpolated =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, KT, RT>(
make_shared_from_ref(context),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseLinears),
waveNumber,
"", NO_SYMMETRY,
false);
BoundaryOperator<BFT, RT> opInterpolated =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, KT, RT>(
make_shared_from_ref(context),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseLinears),
make_shared_from_ref(pwiseLinears),
waveNumber,
"", NO_SYMMETRY,
true);
arma::Mat<RT> matNoninterpolated = opNoninterpolated.weakForm()->asMatrix();
arma::Mat<RT> matInterpolated = opInterpolated.weakForm()->asMatrix();
const CT eps = std::numeric_limits<CT>::epsilon();
BOOST_CHECK(check_arrays_are_close<RT>(
matNoninterpolated, matInterpolated, 100 * eps));
}
示例8: shouldUseBlasInQuadrature
inline bool
shouldUseBlasInQuadrature(const AssemblyOptions &assemblyOptions,
const Space<BasisFunctionType> &domain,
const Space<BasisFunctionType> &dualToRange) {
// Disabled as BLAS quadrature causes crashes in the hypersingular operator for
// unknown reasons.
return assemblyOptions.isBlasEnabledInQuadrature() == AssemblyOptions::YES ||
(assemblyOptions.isBlasEnabledInQuadrature() ==
AssemblyOptions::AUTO &&
(maximumShapesetOrder(domain) >= 2 ||
maximumShapesetOrder(dualToRange) >= 2));
}
示例9: collectOptionsDependentDataForAssemblerConstruction
void
AbstractBoundaryOperator<BasisFunctionType, ResultType>::
collectOptionsDependentDataForAssemblerConstruction(
const AssemblyOptions& options,
const shared_ptr<Fiber::RawGridGeometry<CoordinateType> >& testRawGeometry,
const shared_ptr<Fiber::RawGridGeometry<CoordinateType> >& trialRawGeometry,
shared_ptr<Fiber::OpenClHandler>& openClHandler,
bool& cacheSingularIntegrals) const
{
typedef LocalAssemblerConstructionHelper Helper;
Helper::makeOpenClHandler(options.parallelizationOptions().openClOptions(),
testRawGeometry, trialRawGeometry, openClHandler);
cacheSingularIntegrals = options.isSingularIntegralCachingEnabled();
}
示例10: assert
std::unique_ptr<typename ElementaryLocalOperator<BasisFunctionType,
ResultType>::LocalAssembler>
ElementaryLocalOperator<BasisFunctionType, ResultType>::makeAssembler(
const QuadratureStrategy &quadStrategy,
const AssemblyOptions &options) const {
typedef Fiber::RawGridGeometry<CoordinateType> RawGridGeometry;
typedef std::vector<const Fiber::Shapeset<BasisFunctionType> *>
ShapesetPtrVector;
const bool verbose = (options.verbosityLevel() >= VerbosityLevel::DEFAULT);
shared_ptr<RawGridGeometry> testRawGeometry, trialRawGeometry;
shared_ptr<GeometryFactory> testGeometryFactory, trialGeometryFactory;
shared_ptr<Fiber::OpenClHandler> openClHandler;
shared_ptr<ShapesetPtrVector> testShapesets, trialShapesets;
bool cacheSingularIntegrals;
if (verbose)
std::cout << "Collecting data for assembler construction..." << std::endl;
this->collectDataForAssemblerConstruction(
options, testRawGeometry, trialRawGeometry, testGeometryFactory,
trialGeometryFactory, testShapesets, trialShapesets, openClHandler,
cacheSingularIntegrals);
if (verbose)
std::cout << "Data collection finished." << std::endl;
assert(testRawGeometry == trialRawGeometry);
assert(testGeometryFactory == trialGeometryFactory);
return quadStrategy.makeAssemblerForLocalOperators(
testGeometryFactory, testRawGeometry, testShapesets, trialShapesets,
make_shared_from_ref(testTransformations()),
make_shared_from_ref(trialTransformations()),
make_shared_from_ref(integral()), openClHandler);
}
示例11: reallyMakeAssemblers
std::pair<
shared_ptr<typename HypersingularIntegralOperator<
BasisFunctionType, KernelType, ResultType>::LocalAssembler>,
shared_ptr<typename HypersingularIntegralOperator<
BasisFunctionType, KernelType, ResultType>::LocalAssembler>
>
HypersingularIntegralOperator<BasisFunctionType, KernelType, ResultType>::makeAssemblers(
const QuadratureStrategy& quadStrategy,
const AssemblyOptions& options) const
{
typedef Fiber::RawGridGeometry<CoordinateType> RawGridGeometry;
typedef std::vector<const Fiber::Shapeset<BasisFunctionType>*> ShapesetPtrVector;
const bool verbose = (options.verbosityLevel() >= VerbosityLevel::DEFAULT);
shared_ptr<RawGridGeometry> testRawGeometry, trialRawGeometry;
shared_ptr<GeometryFactory> testGeometryFactory, trialGeometryFactory;
shared_ptr<Fiber::OpenClHandler> openClHandler;
shared_ptr<ShapesetPtrVector> testShapesets, trialShapesets;
bool cacheSingularIntegrals;
if (verbose)
std::cout << "Collecting data for assembler construction..." << std::endl;
this->collectDataForAssemblerConstruction(options,
testRawGeometry, trialRawGeometry,
testGeometryFactory, trialGeometryFactory,
testShapesets, trialShapesets,
openClHandler, cacheSingularIntegrals);
if (verbose)
std::cout << "Data collection finished." << std::endl;
bool makeSeparateOffDiagonalAssembler =
options.assemblyMode() == AssemblyOptions::ACA &&
options.acaOptions().mode == AcaOptions::HYBRID_ASSEMBLY;
return reallyMakeAssemblers(quadStrategy,
testGeometryFactory, trialGeometryFactory,
testRawGeometry, trialRawGeometry,
testShapesets, trialShapesets, openClHandler,
options.parallelizationOptions(),
options.verbosityLevel(),
cacheSingularIntegrals,
makeSeparateOffDiagonalAssembler);
}
示例12: DefaultLocalAssemblerForIntegralOperatorsOnSurfacesManager
DefaultLocalAssemblerForIntegralOperatorsOnSurfacesManager(
bool cacheSingularIntegrals)
{
// Create a Bempp grid
shared_ptr<Grid> grid = createGrid();
// Create context
Fiber::AccuracyOptions options;
options.doubleRegular.setRelativeQuadratureOrder(1);
quadStrategy.reset(new QuadratureStrategy);
AssemblyOptions assemblyOptions;
assemblyOptions.setVerbosityLevel(VerbosityLevel::LOW);
assemblyOptions.enableSingularIntegralCaching(cacheSingularIntegrals);
Context<BFT, RT> context(quadStrategy, assemblyOptions);
// These important thing is that the domain and dualToRange spaces are
// different
piecewiseConstantSpace.reset(new PiecewiseConstantSpace(grid));
piecewiseLinearSpace.reset(new PiecewiseLinearSpace(grid));
bop = laplace3dSingleLayerBoundaryOperator<BFT, RT>(
make_shared_from_ref(context),
piecewiseConstantSpace,
piecewiseLinearSpace,
piecewiseLinearSpace,
"SLP");
const Operator& op = static_cast<const Operator&>(*bop.abstractOperator());
// This would be more elegant than the above, but it doesn't
// work on Mac because of a problem with RTTI across
// shared-library boundaries.
// op = boost::dynamic_pointer_cast<const Operator>(bop.abstractOperator());
// Construct local assembler
assembler = op.makeAssembler(*quadStrategy, assemblyOptions);
}
开发者ID:getzze,项目名称:bempp,代码行数:39,代码来源:test_default_local_assembler_for_integral_operators_on_surfaces.cpp
示例13: assembleWeakFormInSparseMode
std::unique_ptr<DiscreteBoundaryOperator<ResultType>>
ElementaryLocalOperator<BasisFunctionType, ResultType>::
assembleWeakFormInSparseMode(LocalAssembler &assembler,
const AssemblyOptions &options) const {
#ifdef WITH_TRILINOS
if (boost::is_complex<BasisFunctionType>::value)
throw std::runtime_error(
"ElementaryLocalOperator::assembleWeakFormInSparseMode(): "
"sparse-mode assembly of identity operators for "
"complex-valued basis functions is not supported yet");
const Space<BasisFunctionType> &testSpace = *this->dualToRange();
const Space<BasisFunctionType> &trialSpace = *this->domain();
// Fill local submatrices
const GridView &view = testSpace.gridView();
const size_t elementCount = view.entityCount(0);
std::vector<int> elementIndices(elementCount);
for (size_t i = 0; i < elementCount; ++i)
elementIndices[i] = i;
std::vector<arma::Mat<ResultType>> localResult;
assembler.evaluateLocalWeakForms(elementIndices, localResult);
// Global DOF indices corresponding to local DOFs on elements
std::vector<std::vector<GlobalDofIndex>> testGdofs(elementCount);
std::vector<std::vector<GlobalDofIndex>> trialGdofs(elementCount);
std::vector<std::vector<BasisFunctionType>> testLdofWeights(elementCount);
std::vector<std::vector<BasisFunctionType>> trialLdofWeights(elementCount);
gatherGlobalDofs(testSpace, trialSpace, testGdofs, trialGdofs,
testLdofWeights, trialLdofWeights);
// Multiply matrix entries by DOF weights
for (size_t e = 0; e < elementCount; ++e)
for (size_t trialDof = 0; trialDof < trialGdofs[e].size(); ++trialDof)
for (size_t testDof = 0; testDof < testGdofs[e].size(); ++testDof)
localResult[e](testDof, trialDof) *=
conj(testLdofWeights[e][testDof]) * trialLdofWeights[e][trialDof];
// Estimate number of entries in each row
// This will be useful when we begin to use MPI
// // Get global DOF indices for which this process is responsible
// const int testGlobalDofCount = testSpace.globalDofCount();
// Epetra_Map rowMap(testGlobalDofCount, 0 /* index-base */, comm);
// std::vector<int> myTestGlobalDofs(rowMap.MyGlobalElements(),
// rowMap.MyGlobalElements() +
// rowMap.NumMyElements());
// const int myTestGlobalDofCount = myTestGlobalDofs.size();
const int testGlobalDofCount = testSpace.globalDofCount();
const int trialGlobalDofCount = trialSpace.globalDofCount();
arma::Col<int> nonzeroEntryCountEstimates(testGlobalDofCount);
nonzeroEntryCountEstimates.fill(0);
// Upper estimate for the number of global trial DOFs coupled to a given
// global test DOF: sum of the local trial DOF counts for each element that
// contributes to the global test DOF in question
for (size_t e = 0; e < elementCount; ++e)
for (size_t testLdof = 0; testLdof < testGdofs[e].size(); ++testLdof) {
int testGdof = testGdofs[e][testLdof];
if (testGdof >= 0)
nonzeroEntryCountEstimates(testGdof) += trialGdofs[e].size();
}
Epetra_SerialComm comm; // To be replaced once we begin to use MPI
Epetra_LocalMap rowMap(testGlobalDofCount, 0 /* index_base */, comm);
Epetra_LocalMap colMap(trialGlobalDofCount, 0 /* index_base */, comm);
shared_ptr<Epetra_FECrsMatrix> result =
boost::make_shared<Epetra_FECrsMatrix>(
Copy, rowMap, colMap, nonzeroEntryCountEstimates.memptr());
// TODO: make each process responsible for a subset of elements
// Find maximum number of local dofs per element
size_t maxLdofCount = 0;
for (size_t e = 0; e < elementCount; ++e)
maxLdofCount =
std::max(maxLdofCount, testGdofs[e].size() * trialGdofs[e].size());
// Initialise sparse matrix with zeros at required positions
arma::Col<double> zeros(maxLdofCount);
zeros.fill(0.);
for (size_t e = 0; e < elementCount; ++e)
result->InsertGlobalValues(testGdofs[e].size(), &testGdofs[e][0],
trialGdofs[e].size(), &trialGdofs[e][0],
zeros.memptr());
// Add contributions from individual elements
for (size_t e = 0; e < elementCount; ++e)
epetraSumIntoGlobalValues(*result, testGdofs[e], trialGdofs[e],
localResult[e]);
result->GlobalAssemble();
// If assembly mode is equal to ACA and we have AHMED,
// construct the block cluster tree. Otherwise leave it uninitialized.
typedef ClusterConstructionHelper<BasisFunctionType> CCH;
typedef AhmedDofWrapper<CoordinateType> AhmedDofType;
typedef ExtendedBemCluster<AhmedDofType> AhmedBemCluster;
typedef bbxbemblcluster<AhmedDofType, AhmedDofType> AhmedBemBlcluster;
shared_ptr<AhmedBemBlcluster> blockCluster;
shared_ptr<IndexPermutation> test_o2pPermutation, test_p2oPermutation;
//.........这里部分代码省略.........
示例14: main
int main(int argc, char* argv[])
{
// Physical parameters, general
const BFT c0 = 0.3; // speed of light in vacuum [mm/ps]
BFT refind = 1.4; // refractive index
BFT alpha = A_Keijzer(refind); // boundary term
BFT c = c0/refind; // speed of light in medium [mm/ps]
BFT freq = 100*1e6; // modulation frequency [Hz]
BFT omega = 2.0*M_PI * freq*1e-12; // modulation frequency [cycles/ps]
// Physical parameters, outer region
BFT mua1 = 0.01; // absorption coefficient
BFT mus1 = 1.0; // scattering coefficient
BFT kappa1 = 1.0/(3.0*(mua1+mus1)); // diffusion coefficient
RT waveNumber1 = sqrt (RT(mua1/kappa1, omega/(c*kappa1))); // outer region
// Physical parameters, inner region
BFT mua2 = 0.02; // absorption coefficient
BFT mus2 = 0.5; // scattering coefficient
BFT kappa2 = 1.0/(3.0*(mua2+mus2)); // diffusion coefficient
RT waveNumber2 = sqrt (RT(mua2/kappa2, omega/(c*kappa2))); // outer region
// Create sphere meshes on the fly
shared_ptr<Grid> grid1 = CreateSphere(25.0, 1.0);
shared_ptr<Grid> grid2 = CreateSphere(15.0, 1.0);
// Initialize the spaces
PiecewiseLinearContinuousScalarSpace<BFT> HplusHalfSpace1(grid1);
PiecewiseLinearContinuousScalarSpace<BFT> HplusHalfSpace2(grid2);
// Define some default options.
AssemblyOptions assemblyOptions;
// We want to use ACA
AcaOptions acaOptions; // Default parameters for ACA
acaOptions.eps = 1e-5;
assemblyOptions.switchToAcaMode(acaOptions);
// Define the standard integration factory
AccuracyOptions accuracyOptions;
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2);
accuracyOptions.singleRegular.setRelativeQuadratureOrder(1);
NumericalQuadratureStrategy<BFT, RT> quadStrategy(accuracyOptions);
Context<BFT, RT> context(make_shared_from_ref(quadStrategy), assemblyOptions);
// We need the single layer, double layer, and the identity operator
// mesh1 x mesh1
BoundaryOperator<BFT, RT> slp11 =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace1),
SHARED(HplusHalfSpace1), SHARED(HplusHalfSpace1), waveNumber1);
BoundaryOperator<BFT, RT> dlp11 =
modifiedHelmholtz3dDoubleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace1),
SHARED(HplusHalfSpace1), SHARED(HplusHalfSpace1), waveNumber1);
BoundaryOperator<BFT, RT> id11 =
identityOperator<BFT, RT>(
SHARED(context), SHARED(HplusHalfSpace1),
SHARED(HplusHalfSpace1), SHARED(HplusHalfSpace1));
// mesh2 x mesh2, wavenumber 1
BoundaryOperator<BFT, RT> slp22_w1 =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace2), SHARED(HplusHalfSpace2), waveNumber1);
BoundaryOperator<BFT, RT> dlp22_w1 =
modifiedHelmholtz3dDoubleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace2), SHARED(HplusHalfSpace2), waveNumber1);
BoundaryOperator<BFT, RT> id22 =
identityOperator<BFT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace2), SHARED(HplusHalfSpace2));
// mesh2 x mesh2, wavenumber 2
BoundaryOperator<BFT, RT> slp22_w2 =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace2), SHARED(HplusHalfSpace2), waveNumber2);
BoundaryOperator<BFT, RT> dlp22_w2 =
modifiedHelmholtz3dDoubleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace2), SHARED(HplusHalfSpace2), waveNumber2);
// mesh1 x mesh2
BoundaryOperator<BFT, RT> slp12 =
modifiedHelmholtz3dSingleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace1), SHARED(HplusHalfSpace1), waveNumber1);
BoundaryOperator<BFT, RT> dlp12 =
modifiedHelmholtz3dDoubleLayerBoundaryOperator<BFT, RT, RT>(
SHARED(context), SHARED(HplusHalfSpace2),
SHARED(HplusHalfSpace1), SHARED(HplusHalfSpace1), waveNumber1);
// mesh2 x mesh1
//.........这里部分代码省略.........
示例15: main
int main(int argc, char* argv[])
{
// Load mesh
if (argc != 2) {
std::cout << "Solve a Dirichlet problem for the Laplace equation.\n"
"Usage: " << argv[0] << " <mesh_file>" << std::endl;
return 1;
}
shared_ptr<Grid> grid = loadTriangularMeshFromFile(argv[1]);
//std::cout << grid->gridTopology() << std::endl;
// Initialize the spaces
PiecewiseLinearContinuousScalarSpace<BFT> HplusHalfSpace(grid);
PiecewiseConstantScalarSpace<BFT> HminusHalfSpace(grid);
// Define some default options.
AssemblyOptions assemblyOptions;
// We want to use ACA
AcaOptions acaOptions; // Default parameters for ACA
acaOptions.eps = 1e-5;
assemblyOptions.switchToAcaMode(acaOptions);
// Define the standard integration factory
AccuracyOptions accuracyOptions;
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(1);
NumericalQuadratureStrategy<BFT, RT> quadStrategy(accuracyOptions);
Context<BFT, RT> context(make_shared_from_ref(quadStrategy), assemblyOptions);
// We need the single layer, double layer, and the identity operator
BoundaryOperator<BFT, RT> slpOp = laplace3dSingleLayerBoundaryOperator<BFT, RT >(
make_shared_from_ref(context),
make_shared_from_ref(HminusHalfSpace),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HminusHalfSpace),
"SLP");
BoundaryOperator<BFT, RT> dlpOp = laplace3dDoubleLayerBoundaryOperator<BFT, RT >(
make_shared_from_ref(context),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HminusHalfSpace),
"DLP");
BoundaryOperator<BFT, RT> id = identityOperator<BFT, RT>(
make_shared_from_ref(context),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HminusHalfSpace),
"I");
// Form the right-hand side sum
BoundaryOperator<BFT, RT> rhsOp = -0.5 * id + dlpOp;
// We also want a grid function
GridFunction<BFT, RT> u(
make_shared_from_ref(context),
make_shared_from_ref(HplusHalfSpace),
make_shared_from_ref(HplusHalfSpace), // is this the right choice?
surfaceNormalIndependentFunction(MyFunctor()));
// Assemble the rhs
std::cout << "Assemble rhs" << std::endl;
GridFunction<BFT, RT> rhs = rhsOp * u;
// Initialize the solver
std::cout << "Initialize solver" << std::endl;
#ifdef WITH_TRILINOS
DefaultIterativeSolver<BFT, RT> solver(slpOp,ConvergenceTestMode::TEST_CONVERGENCE_IN_DUAL_TO_RANGE);
solver.initializeSolver(defaultGmresParameterList(1e-5));
Solution<BFT, RT> solution = solver.solve(rhs);
std::cout << solution.solverMessage() << std::endl;
#else
DefaultDirectSolver<BFT, RT> solver(slp, rhs);
solver.solve();
#endif
// Extract the solution
const GridFunction<BFT, RT>& solFun = solution.gridFunction();
// Write out as VTK
solFun.exportToVtk(VtkWriter::CELL_DATA, "Neumann_data",
"calculated_neumann_data_cell");
solFun.exportToVtk(VtkWriter::VERTEX_DATA, "Neumann_data",
"calculated_neumann_data_vertex");
// Uncomment the block below if you are solving the problem on a sphere and
//.........这里部分代码省略.........