Comments (4)
Hi Mikhail,
If you add two BilinerFormIntegrators the corresponding BilinearForm will assemble their sum, see for example
https://github.com/mfem/mfem/blob/master/examples/ex3.cpp#L126
Does this address your use case?
You should be able to write
M += D
for sparse matrices M and D, as long as the sparsity patter on D is a subset of the sparsity patter of M (which very likely is true), see
https://github.com/mfem/mfem/blob/master/linalg/sparsemat.hpp#L279
Hope this helps,
Tzanio
from mfem.
Hi Tzanio,
If you add two BilinerFormIntegrators the corresponding BilinearForm will assemble their sum
I think this is indeed possible in my case, but I thought that since I already computed M and D as separate matrices there should be any easy way to add them up, and creating a new bilinear form didn't look as the one.
You should be able to write M += D
I can't because in this case I change M, but I need the original one for the right hand side (the same is true for D).
for sparse matrices M and D, as long as the sparsity patter on D is a subset of the sparsity patter of M
I think I can add them up even if the patterns are completely different, but the height and width are the same, and both are not finalized. Please, let me know if I'm wrong.
As for the copying sparse matrices (just to close the topic) - there is no way to do that as far as I understood. Correct?
Best regards,
Mikhail
from mfem.
Hi Mikhail,
Copying a SparseMatrix can be achieved with something like this:
// Assume we have a SparseMatrix A that is finalized, i.e. in csr format.
int nnz = A.NumNonZeroElems();
SparseMatrix B(A.GetI(), A.GetJ(), new double[nnz], A.Height(), A.Width(),
false, true, A.areColumnsSorted());
B = 0.0;
B += A;
The new SparseMatrix B has the same sparsity pattern as A without duplicating the "I" and "J" arrays of the csr format, only the "data" double array is different and it will be owned by the newly created SparseMatrix B, i.e. B will delete its "data" array when it is destroyed.
An actual copy constructor for SparseMatrix will be available in the next release of MFEM.
Veselin
from mfem.
Hi Veselin,
That looks like a solution! Thank you!
Best,
Mikhail
from mfem.
Related Issues (20)
- How to prevent negative value with Legendre basis? HOT 2
- Maximum matrix sizes HOT 8
- Implementing smoothness indicators with ProjectGrad HOT 2
- CalcHessian for 2D triangle is not implemented when mesh is linear.
- A typo in the definition of the VDIM? HOT 1
- How to get the center coordinate of a nedelec basis function
- Why not directly use the easily computable basis functions? in the question 566 HOT 1
- VisItDataCollection broken for L2 fields as of visit 3.4.0 HOT 10
- Behaviour of DiffusionIntegrator when used as boundary integrator
- The best way to define auxiliary freedoms on part of the region HOT 1
- Possible initialization bug for `LORSolver<HypreBoomerAMG>` HOT 3
- Create coefficient from file. HOT 12
- NURBSMeshRules::Finalize(Mesh const& mesh) only work on 3D HOT 1
- Non-linear time-dependent problem HOT 1
- 【How to implement the RT projection locally】 HOT 3
- Missing documentation
- Boundary LF Integrators fast assembly minor bug
- Periodical BC and the GetVertex function HOT 11
- Electromagnetic skin effect in different wire shapes, in 2D. HOT 3
- Unexpected performance of different preconditioners HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mfem.