Hot answers tagged

9 votes

Direct Numerical Simulation of reacting flows

Like WolfgangBangerth, I strongly recommend that you reconsider your motivation (or your supervisor's motivation) for this goal. First, look at Center for Exascale Simulation of Combustion in ...
9 votes
Accepted

FEM for vector valued problems: reference request

Short answer: Just replicate the vector of interpolation functions into a block-diagonal matrix, as showed e.g. on page 5 in this lecture note. Detailed answer: Mathematically oriented texts typically ...
5 votes

k nearest neighbors dictionary for vectors?

What you're describing is also a critical step in the k-nearest-neighbours method. So no need to reinvent the wheel, we can just look how other people have sped up that algorithm. I don't know about ...
  • 1,266
4 votes

How to compute the Helmholtz decomposition of 2D and 3D vector fields?

The short answer is "It depends". Certainly, you can try to find the Helmholtz decomposition on your sampled data, and find your irrotational and solenoidal components. However, there are certain ...
  • 8,542
4 votes

Direct Numerical Simulation of reacting flows

What you suggest is a multi-year research program. Don't even think about doing this yourself, you will not within several years achieve anything that comes close to the current research. Rather, ...
4 votes

FEM for vector valued problems: reference request

We can show how it works on the example of linear elasticity. In classical finite elements formulations, on every node, we will have a scalar shape (base) function to which we have associated number ...
  • 906
4 votes

In Eigen, can a sparse matrix contain vectors/objects instead of simple scalar values?

Certainly. There are a few things you have to define for your type that are listed on this page in the documentation: https://eigen.tuxfamily.org/dox/TopicCustomizing_CustomScalar.html It basically ...
  • 1,522
3 votes
Accepted

Algorithm to merge two polygons (using connectivities)?

Easy: Decompose the polygons into (unoriented) line segments each of which is sorted by vertex index: $$ A = \{[1,2], [2,3], [3,4], [4,5], [1,5]\}, \\ B = \{ [1,6], [6,7],[7,8],[3,8], [2,3], [1,2]...
3 votes

How can one produce a proper streamline plot?

You can calculate the stream function yourself, and from it you can draw contours or streamlines of constant $\psi$. Let us assume you are on a two-dimensional incompressible flow $\mathbf{u}=(u,v,0)^...
  • 261
2 votes

Plot vector field in matlab

For plotting, it is easier in my opinion to not use meshgrid if you want to scale the arrows. You have a vector field $(E_X, E_Z)$ and you can simply normalize it like in the code below: ...
  • 187
2 votes

Arranging variable ranges into a cell MATLAB

you just need to add output to your min() function, e.g.: [value, ind] = min(v) ind is ...
  • 137
2 votes
Accepted

Vector characterization of cylinder displacements in a box

You're correct, if the orientational vector is unitary. Otherwise you must calculate the unitary vector in the direction of $\vec{O}_1$ and then perform the projection (just divide by the norm of the ...
2 votes
Accepted

How to deal with numerical errors in electrostatic field calculations

I will try to answer the part of the question regarding the accuracy of the calculation, which certainly affects all the other things. Integrals of the type ($T_j$ denoting the $j$th triangle in the ...
  • 8,542
2 votes
Accepted

Find representatives of vector-space in set of vectors?

You can think of each vector as a point in your linear space. As such, we can use a simple quadtree/octree-like algorithm to map your points into boxes, with "nearby" vectors assigned to the same or ...
  • 663
2 votes

In Lanczos algorithm, can we choose the staring vector to be the first eigenvector of the input matrix A?

Of course you can! The starting vector is completely arbitrary. You'll get breakdown at step 1 if you do though. Be sure to check what it entails. This will typically happen by a "happy accident&...
1 vote
Accepted

Computing excited states using itensor (with DMRG)

For anyone interested in this problem, I found the following solution: ...
1 vote
Accepted

Solving Vectorial Poisson Equation in FENICS

Ok I will answer my own question: The problem is in the line solve(L==a,A,bc) which needs to be replaced by solve(a==L,A,bc). ...
  • 121
1 vote

Plotting or Visualizing a Higher dimensional vector field

Somehow I have to use t-sne, but I really don't know how. Since you have a PhD my answer will be brief, it's quite a lengthy subject. The aim of dimensionality reduction is to preserve as much of ...
  • 111
1 vote

Find representatives of vector-space in set of vectors?

Initialize the cluster centers as your subset $V\in X$, where $V=\{x_i\}$. Then run a couple of K-mediods iterations. After that you will see that the certain vectors will come closer, essentially ...
  • 2,169
1 vote

Find representatives of vector-space in set of vectors?

Sounds like you want to thin your data where it is dense, and learn the support of your data summarized by data points. If you don't have too many points, you can generate a distance matrix, and prune ...
  • 860
1 vote
Accepted

Software/code to extract a solenoidal (a.k.a. divergence-free) field from a 2D vector field numerically

After some searching I found a C/C++ function called project() in the article 'Real-Time Fluid Dynamics for Games' by Jos Stam http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf I ...
  • 141
1 vote
Accepted

two level iterators C++

While I don't state this to be an optimal implementation or one taking into account the all edge cases, below is a sample implementation I put together for your task that can give you an idea of how ...
  • 3,788
1 vote

Find a permutation matrix (using the Matlab's function $symrcm$) of a matrix $A(2:end, 2:end)$

From your comment "The plot emphasises expectedly the connections of node 1", I guess that maybe the idea is showing that node 1 is connected not only to a set of nodes that are "one close to the ...
1 vote

Efficiently approximating sum of 2-norms

If you just want an approximation to the sum of their norms, you can choose a random sample of $m$ of the indices (i.e., a random set $S \subseteq \{1,2,\dots,N\}$ of size $m$) and compute $$f(\...
  • 370
1 vote
Accepted

Vector and index notation equivalence

Is it possible to tell in index notation whether a vector is a row or column vector, or is that supposed to be clear based on context? It seems the answer is actually lurking in your question itself ...
1 vote
Accepted

Sparse matrix vector product using PETSC

I assume that you are comparing multiplication with an assembled PETSc matrix with your hand-coded matrix-free method. The latter may indeed be faster, but this could be because no entries of ...
1 vote
Accepted

Rotate 2D shape around origin in a 3D space

You should take a look at the Wikipedia page on rotation matrices, specifically the section on forming a rotation matrix from an axis and an angle. In your case, you have a vector $\vec{v}$ that you ...

Only top scored, non community-wiki answers of a minimum length are eligible