Assemble finite element matrix without varf

Dear all,

I am trying to assemble a finite element matrix with “custom” local submatrices.
The pseudo-code is the following:

// For each element
for (int i=0;i<Th.nt;i++){
	// Calculate elemental submatrix
	m_e = ...;

	// Global Assembly
	Assemble(M, m_e, i);
}

My question is then the following: What is the function “Assemble” (in the pseudocode)?

I am sure that this function is already present in the source code, but I can’t find it. And also, can I call it in a user script?

Thank you in advance for your help.

Yes this function existe but this fonction is not interface in the language.

Question why you need to do this …

I am trying to implement an upwind scheme based on the residual (or fluctuation) splitting method. The details of the method can be found in this article by H. Deconinck, “Multidimensional upwind schemes based on fluctuation-splitting for systems of conservation laws” (1993).

The main idea is to improve the contribution of the nodes upwind the gradient of a certain quantity.
In order to do that, I calculate an average “advection” speed over the element and calculate the coefficients k_i which are one half of the scalar product of the average advection speed and n_i.
Where n_i are the inward normal vector to the face opposed to the node i. Then, depending on the coefficients k_i, I can choose how to improve the contribution of the nodes upwind the flow.

Depending on the method used for this last step, the resulting scheme is a Low Diffusion A Scheme, a N-scheme or a PSI-scheme.

Maybe these schemes are very close to the upwind method already implemented in Freefem and I can try to use this one.

You have in plugin example c++ code https://github.com/FreeFem/FreeFem-sources/blob/master/plugin/seq/mat_psi.cpp very close to you problem.