G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsGridHierarchy.hpp
Go to the documentation of this file.
1
14#pragma once
15
19#include <gsIO/gsOptionList.h>
21#include <gsCore/gsMultiBasis.h>
22
23namespace gismo
24{
25
26template <typename T>
28 gsMultiBasis<T> mBasis,
29 const gsBoundaryConditions<T>& boundaryConditions,
30 const gsOptionList& options,
31 index_t levels,
32 index_t numberOfKnotsToBeInserted,
33 index_t multiplicityOfKnotsToBeInserted,
34 index_t unk
35 )
36{
37 gsGridHierarchy<T> result;
38 result.m_mBases.resize(levels);
39 result.m_transferMatrices.resize(levels-1);
40 result.m_mBases[0] = give(mBasis);
41 for ( index_t i=1; i<levels; ++i )
42 {
43 result.m_mBases[i] = result.m_mBases[i-1];
44 result.m_mBases[i].uniformRefine_withTransfer(
45 result.m_transferMatrices[i-1],
46 boundaryConditions,
47 options,
48 numberOfKnotsToBeInserted,
49 multiplicityOfKnotsToBeInserted,
50 unk
51 );
52 }
53 return result;
54}
55
56template <typename T>
58 gsMultiBasis<T> mBasis,
59 const gsBoundaryConditions<T>& boundaryConditions,
60 const gsOptionList& options,
61 index_t levels,
62 index_t degreesOfFreedom,
63 index_t unk
64 )
65{
66 gsGridHierarchy<T> result;
67
68 result.m_mBases.push_back(give(mBasis));
69
70 index_t lastSize = result.m_mBases[0].totalSize();
71
72 for (index_t i = 0; i < levels-1 && lastSize > degreesOfFreedom; ++i)
73 {
74 gsSparseMatrix<T, RowMajor> transferMatrix;
75 gsMultiBasis<T> coarseMBasis = result.m_mBases[i];
76 coarseMBasis.uniformCoarsen_withTransfer(
77 transferMatrix,
78 boundaryConditions,
79 options,
80 1,
81 unk
82 );
83
84 index_t newSize = coarseMBasis.totalSize();
85 // If the number of dofs could not be decreased, then cancel. However, if only the number
86 // of levels was specified, then this should be ignored (the caller might need to have a
87 // fixed number of levels).
88 if (lastSize <= newSize && degreesOfFreedom > 0)
89 break;
90 lastSize = newSize;
91
92 result.m_mBases.push_back(give(coarseMBasis));
93 result.m_transferMatrices.push_back(give(transferMatrix));
94 }
95
96 std::reverse( result.m_mBases.begin(), result.m_mBases.end() );
97 std::reverse( result.m_transferMatrices.begin(), result.m_transferMatrices.end() );
98
99 return result;
100}
101
102} // namespace gismo
Class containing a set of boundary conditions.
Definition gsBoundaryConditions.h:342
Grid Hierarchy.
Definition gsGridHierarchy.h:34
static gsGridHierarchy buildByRefinement(gsMultiBasis< T > mBasis, const gsBoundaryConditions< T > &boundaryConditions, const gsOptionList &assemblerOptions, index_t levels, index_t numberOfKnotsToBeInserted=1, index_t multiplicityOfKnotsToBeInserted=1, index_t unk=0)
This function sets up a multigrid hierarchy by uniform refinement.
Definition gsGridHierarchy.hpp:27
static gsGridHierarchy buildByCoarsening(gsMultiBasis< T > mBasis, const gsBoundaryConditions< T > &boundaryConditions, const gsOptionList &assemblerOptions, index_t levels, index_t degreesOfFreedom=0, index_t unk=0)
This function sets up a grid hierarchy by coarsening.
Definition gsGridHierarchy.hpp:57
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
size_t totalSize() const
The total number of basis functions in all bases.
Definition gsMultiBasis.h:246
void uniformCoarsen_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, const gsBoundaryConditions< T > &boundaryConditions, const gsOptionList &assemblerOptions, int numKnots=1, index_t unk=0)
Coarsen every basis uniformly.
Definition gsMultiBasis.hpp:222
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
Provides assembler and solver options.
Provides declaration of BSplineBasis class.
#define index_t
Definition gsConfig.h:32
Knot vector for B-splines.
Provides declaration of MultiBasis class.
Provides a list of labeled parameters/options that can be set and accessed easily.
Provides declaration of TensorBSplineBasis abstract interface.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266