Hermes2DFunction in CustomWeakForms

73 views
Skip to first unread message

Tomas Svaton

unread,
Oct 6, 2013, 6:14:26 PM10/6/13
to herm...@googlegroups.com
Hello everybody,

When defining the own weak forms I would like to use the variable as Hermes2DFunction like, but it seems quite hard. The principal problem, that only two arguments are to be overridden in the original class. Then may be called in definitions.cpp : lambdaF->value(u_ext[0]->val[i], u_ext[1]->val[i]). But I would like to pass all the derivatives something like lambdaF->value(u_ext[0]->dx[i], u_ext[0]->dy[i], u_ext[1]->dx[i], u_ext[1]->dy[i]). So the four arguments are needed to be passed. Could someone advice how to proceed?

I thought also about the solution to pass only two variables and then find the derivatives in the frame of defined Hermes2DFunction, but I find it quite impossible.

Let me know, if I am wrong with something.

Thank you in advance for your help.

Kind regards,
Tomas.

Lukas Korous

unread,
Oct 7, 2013, 4:19:00 AM10/7/13
to herm...@googlegroups.com
Hi,

actually quite recently we addressed this issue in hermes as well, by
introducing UExtFunction class.

It is exactly what you are after, and it is done so (unlike calling
some value(...) in the loop over the integration points) to achieve
better performance.

It is available in the devel branch, that will very soon become the
master branch.

The example use of the class follows:

class CustomUExtFunction : public UExtFunction<double>
{
public:
CustomUExtFunction(MeshSharedPtr mesh) : UExtFunction<double>(mesh)
{
}

virtual void value (int n, Func<double>** u_ext, Func<double>*
result, Geom<double>* geometry) const
{
for(int i = 0; i < n; i++)
{
result->val[i] = u_ext[index]->val[i];
result->dx[i] = u_ext[index]->dx[i];
result->dy[i] = u_ext[index]->dy[i];
}
};

virtual void ord(Func<Hermes::Ord>** u_ext, Func<Hermes::Ord>* result) const
{
result->val[0] = u_ext[index]->val[0];
};

MeshFunction<double>* clone() const
{
return new CustomUExtFunction(this->mesh);
};
};

And this is just a function you would pass to your Weakform in the ext
array, using Weakform::set_ext(...).

Could you give it a shot?

Thanks,
Lukas
> --
> You received this message because you are subscribed to the Google Groups
> "hermes2d" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hermes2d+u...@googlegroups.com.
> To post to this group, send email to herm...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hermes2d.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Lukáš Korous

Tomas Svaton

unread,
Oct 7, 2013, 3:30:55 PM10/7/13
to herm...@googlegroups.com
Hi Lukas,

Thank you for your help. This will be very useful. I began to update the hermes to devel version via git.
... hiting the commands:
$ git fetch upstream
$ git stash
$ git merge upstream/devel

Built paralution
installed mongoDB for having BSON
built and installed matio also with zlib and hdf5
installed tcmalloc
already having MUMPS

I tried to run vary times cmake . and make consequently, but several errors related with the libraries in CMake.vars (I enclose it).

Could you take a look on this config, please?

Thank you very much.

Kind regards,
Tomas.

PS Some errors related with build:
tomas@tomas-VirtualBox:~/workspace/hermes$ make
Scanning dependencies of target hermes_common-debug
[  0%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/mixins.cpp.o
In file included from /home/tomas/workspace/hermes/hermes_common/include/mixins.h:25:0,
                 from /home/tomas/workspace/hermes/hermes_common/src/mixins.cpp:15:
/home/tomas/workspace/hermes/hermes_common/include/common.h:71:18: fatal error: bson.h: No such file or directory
compilation terminated.

=======

tomas@tomas-VirtualBox:~/workspace/hermes$ make
[  0%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/mixins.cpp.o
In file included from /home/tomas/workspace/hermes/hermes_common/include/mixins.h:25:0,
                 from /home/tomas/workspace/hermes/hermes_common/src/mixins.cpp:15:
/home/tomas/workspace/hermes/hermes_common/include/common.h:66:22: fatal error: tcmalloc.h: No such file or directory
compilation terminated.
CMake.vars

Lukas Korous

unread,
Oct 8, 2013, 3:22:02 AM10/8/13
to herm...@googlegroups.com
Hi Tomas,

is this windows or linux?

Also, you mention problems with CMake, did CMake find TCMalloc and
BSON correctly?

Could you also please try without these two, or to start from a safe
side, without any optional stuff (turn off what you can in your
CMake.vars file).

Right now, I am actually working on releasing the 3.0 version, it will
be this week and I will be happy if you could give it a test ride once
it's out.

Regards,
Lukas

Tomas Svaton

unread,
Oct 8, 2013, 5:43:27 AM10/8/13
to herm...@googlegroups.com
Hi Lukas,

It is great about the new version of hermes. I will be glad to perform some test when it will be released. I am working on Ubuntu linux with Hermes.

I looked once more on the libraries. Infact the BSON and TCMalloc I can not find still their position in the file structure.

I switched off all optionaly stuff and followed with 
$rm CMakeCache.txt
$make clean
$cmake .
$make
The compilation stopped on 28%.

The logs are bellow and CMake.vars enclosed to this e-mail.

Kind regards,
Tomas.

PS Logs:
tomas@tomas-VirtualBox:~/workspace/hermes$ cmake .
-- Hermes will by default be using 4 threads for calculation.
-- Found PTHREAD: /usr/lib/i386-linux-gnu/libpthread.so  
-- Found XSD: /usr/include  
-- Found XERCES: /usr/lib/i386-linux-gnu/libxerces-c.so  
-- Found UMFPACK: /usr/lib/libumfpack.so;/usr/lib/libamd.so  
-- Looking for Fortran dgemm
-- Looking for Fortran dgemm - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- A library with BLAS API found.
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- A library with LAPACK API found.
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp  
-- Looking for fmemopen
-- Looking for fmemopen - found
-- Looking for log2
-- Looking for log2 - not found

Hermes Configuration results
---------------------
Build static libs: NO

-------Features-------
Build with OpenMP: YES
Build with TCMalloc: NO
Build with BSON: NO
Build with MATIO: NO
Build with EXODUSII: NO

-------Solvers-------
Build with UMFPACK: YES
Build with PARALUTION: NO
Build with PETSC: NO
Build with MUMPS: NO
Build with SUPERLU: NO
Build with TRILINOS: NO

-----Hermes common-----
 Debug version: YES
 Release version: NO

-----Hermes2D-----
 Build Hermes2D: YES
 Debug version: YES
 Release version: NO
 Test examples: YES
 Hermes2D with OpenGL: NO
---------------------


-- Configuring done
-- Generating done
-- Build files have been written to: /home/tomas/workspace/hermes



tomas@tomas-VirtualBox:~/workspace/hermes$ make
Scanning dependencies of target hermes_common-debug
[  0%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/mixins.cpp.o
[  1%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/ord.cpp.o
[  2%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/hermes_function.cpp.o
[  2%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/exceptions.cpp.o
[  3%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/api.cpp.o
[  3%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/algebra_utilities.cpp.o
[  4%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/matrix.cpp.o
[  4%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/vector.cpp.o
[  5%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/algebra_mixins.cpp.o
[  6%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/dense_matrix_operations.cpp.o
[  6%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/algebra/cs_matrix.cpp.o
[  7%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/util/callstack.cpp.o
[  7%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/util/qsort.cpp.o
[  8%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/data_structures/range.cpp.o
[  8%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/data_structures/table.cpp.o
[  9%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/matrix_solver.cpp.o
[  9%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/linear_matrix_solver.cpp.o
[ 10%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/nonlinear_matrix_solver.cpp.o
[ 11%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/picard_matrix_solver.cpp.o
[ 11%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/newton_matrix_solver.cpp.o
[ 12%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/nonlinear_convergence_measurement.cpp.o
[ 12%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/epetra.cpp.o
[ 13%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/aztecoo_solver.cpp.o
[ 13%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/amesos_solver.cpp.o
[ 14%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/mumps_solver.cpp.o
[ 15%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/paralution_solver.cpp.o
[ 15%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/superlu_solver.cpp.o
[ 16%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/superlu_solver_real.cpp.o
[ 16%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/superlu_solver_cplx.cpp.o
[ 17%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/petsc_solver.cpp.o
[ 17%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/umfpack_solver.cpp.o
[ 18%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/precond_ml.cpp.o
[ 19%] Building CXX object hermes_common/CMakeFiles/hermes_common-debug.dir/src/solvers/interfaces/precond_ifpack.cpp.o
Linking CXX shared library libhermes_common-debug.so
[ 19%] Built target hermes_common-debug
Scanning dependencies of target XSDMesh1D
[ 20%] Generating include/mesh/mesh_h1d_xml.h, src/mesh/mesh_h1d_xml.cpp
[ 20%] Built target XSDMesh1D
Scanning dependencies of target XSDMesh2D
[ 20%] Generating include/mesh/mesh_h2d_xml.h, src/mesh/mesh_h2d_xml.cpp
[ 20%] Built target XSDMesh2D
Scanning dependencies of target XSDSolution2D
[ 21%] Generating include/function/solution_h2d_xml.h, src/function/solution_h2d_xml.cpp
[ 21%] Built target XSDSolution2D
Scanning dependencies of target XSDSpace2D
[ 21%] Generating include/space/space_h2d_xml.h, src/space/space_h2d_xml.cpp
[ 21%] Built target XSDSpace2D
Scanning dependencies of target XSDSubdomains2D
[ 22%] Generating include/mesh/subdomains_h2d_xml.h, src/mesh/subdomains_h2d_xml.cpp
[ 22%] Built target XSDSubdomains2D
Scanning dependencies of target hermes2d-debug
[ 22%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/boundary_conditions/essential_boundary_conditions.cpp.o
[ 23%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/api2d.cpp.o
[ 23%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/graph.cpp.o
[ 24%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/mixins2d.cpp.o
[ 25%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/weakform/weakform.cpp.o
[ 25%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/neighbor_search.cpp.o
[ 26%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/norm_form.cpp.o
[ 26%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/spline.cpp.o
[ 27%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/forms.cpp.o
[ 27%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/asmlist.cpp.o
[ 28%] Building CXX object hermes2d/CMakeFiles/hermes2d-debug.dir/src/projections/ogprojection.cpp.o
In file included from /home/tomas/workspace/hermes/hermes2d/include/discrete_problem/discrete_problem_cache.h:20:0,
                 from /home/tomas/workspace/hermes/hermes2d/include/discrete_problem.h:24,
                 from /home/tomas/workspace/hermes/hermes2d/include/solver/solver.h:25,
                 from /home/tomas/workspace/hermes/hermes2d/include/solver/linear_solver.h:25,
                 from /home/tomas/workspace/hermes/hermes2d/src/projections/ogprojection.cpp:18:
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:131:1: error: expected unqualified-id before ‘<<’ token
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:133:35: error: ‘ProjNormType’ has not been declared
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:134:1: error: expected unqualified-id before ‘==’ token
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:138:1: error: expected unqualified-id before ‘>>’ token
make[2]: *** [hermes2d/CMakeFiles/hermes2d-debug.dir/src/projections/ogprojection.cpp.o] Error 1
make[1]: *** [hermes2d/CMakeFiles/hermes2d-debug.dir/all] Error 2
make: *** [all] Error 2
CMake.vars

Lukas Korous

unread,
Oct 8, 2013, 8:55:46 AM10/8/13
to herm...@googlegroups.com
Hi Tomas,

my guess would be that your merge failed and you still have conflicts
in your git tree:

/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:131:1:
error: expected unqualified-id before ‘<<’ token
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:133:35:
error: ‘ProjNormType’ has not been declared
/home/tomas/workspace/hermes/hermes2d/include/adapt/adapt.h:134:1:
error: expected unqualified-id before ‘==’ token

could be something like

<<<<<<<<<<<<<<<< One commit
stuff
================
other stuff
>>>>>>>>>>>>> Other commit

Could you check please?

Also, it is better to be safe when merging and doing some git fetch
origin devel:totally-new-branch, and then git checkout
totally-new-branch if you know what I mean.

The point is that the current devel branch should work just fine, we
test every day - on Ubuntu and Windows.

About BSON and TCMalloc, with every library you need just two things -
libraries (*.so, *.a), and headers (*.h, *.hpp,
*.sometimes-some-weird-extension), just look for those in the
installation directories.

Lukas

Tomas Svaton

unread,
Oct 8, 2013, 8:15:13 PM10/8/13
to herm...@googlegroups.com
Hi Lukas,

It works well. Thank you very much for your estimation. The problem was realy in the conflict content, which I fixed with vimdiff. 

Just two "details" about the libraries. For the TCMalloc it was simple to find libraries in the file structure. What I can not find is BSON. Probably it is because that I do not have installed the write libraries at all. The second task are MUMPS libraries. I installed both mumps-4.10.0 and mumps-dev. I know the libraries are in /usr/lib and header files in /usr/include, but for any configuration in CMake.vars I get the following after cmake .

tomas@tomas-VirtualBox:~/workspace/hermes$ cmake .
-- Hermes will by default be using 4 threads for calculation.
-- MUMPSC_SEQ_FORTRAN_LIBRARY not found - if WinMUMPS is used, this is an error.
-- MUMPSS_SEQ_FORTRAN_LIBRARY not found - if WinMUMPS is used, this is an error.
-- MUMPSD_SEQ_FORTRAN_LIBRARY not found - if WinMUMPS is used, this is an error.
-- MUMPSZ_SEQ_FORTRAN_LIBRARY not found - if WinMUMPS is used, this is an error.
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message):
  Could NOT find MUMPS (missing: MUMPS_INCLUDE_PATH)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindMUMPS.cmake:77 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:404 (find_package)


-- Configuring incomplete, errors occurred!
tomas@tomas-VirtualBox:~/workspace/hermes$

I enclose the file CMake.vars If you could take a look.

Thank you.

Kind regards,
Tomas.
CMake.vars

Lukas Korous

unread,
Oct 9, 2013, 3:42:00 AM10/9/13
to herm...@googlegroups.com
Hi Tomas,

could you check that "mumps_c_types.h " is in your include directory?

Also, if you set WITH_MPI to YES, you must have "mpi.h" in the directory.

Lukas

Tomas Svaton

unread,
Oct 9, 2013, 8:22:47 AM10/9/13
to herm...@googlegroups.com
Hi Lukas,

I checked it:
tomas@tomas-VirtualBox:/usr/include$ find -name mpi.h
./mumps_seq/mpi.h
tomas@tomas-VirtualBox:/usr/include$ find -name mumps_c_types.h
./mumps_c_types.h

Tomas.

Lukas Korous

unread,
Oct 15, 2013, 3:53:23 PM10/15/13
to herm...@googlegroups.com
Hi,

sorry for delay.

You know what, let us start from the simplest thing, turn off MUMPS
(SET WITH_MUMPS NO), turn off everything you can, and then remove the
old CMakeCache.txt file (in root), and issue "cmake ." again.

Let us go from there.

Lukas

Tomas Svaton

unread,
Oct 15, 2013, 8:28:45 PM10/15/13
to herm...@googlegroups.com
Hi Lukas,

Good idea, everything switched off as in enclosed CMake.vars. Then

$make clean
$rm CMakeCache.txt
$cmake .
$make
$sudo make clean

The proper text outputs are in the files hermes.txt

Then I gone to hermes-tutorial switched off the same tasks in CMake.vars (enclosed as CMake.vars.ht) and performed the same steps as for building hermes. Appeared error and output are in the files hermesTutorial.txt

Thank you very much for your help.

Kind regards,
Tomas.
CMake.vars
hermes.txt
CMake.vars.ht
hermesTutorial.txt

Lukas Korous

unread,
Oct 16, 2013, 5:44:06 AM10/16/13
to herm...@googlegroups.com
Hi,

looks good. But you have some old hermes installation in /usr/local/lib:

-- Found HERMES_COMMON: /usr/local/lib/libhermes_common.so
-- Found HERMES: /usr/local/lib/libhermes2d.so

and you are installing only the debug version:

set(HERMES_COMMON_RELEASE NO)
set(H2D_RELEASE NO)

So, the simple solution is to:

either
1) delete /usr/local/lib/libhermes_common.so + /usr/local/lib/libhermes2d.so
2) rm CMakeCache.txt (cmake temp file) from hermes-tutorial root
3) do cmake . there again, you should see it finding the correct (new) libraries

or

1) just build also the new release version:
set(HERMES_COMMON_RELEASE YES)
set(H2D_RELEASE YES)

Could you try?

Thanks

Lukas

Tomas Svaton

unread,
Oct 17, 2013, 4:51:10 PM10/17/13
to herm...@googlegroups.com
Hi Lukas,

Great! I am very happy to go on with work :o) Thank you very much it was the crucial problem about the old libraries in the directory. I deleted them and now the compilation of the hermes-tutorial works well. For me is sufficient now. Just one note about the compilation of the hermes-examples, it stops at 33% I enclose the CMake.vars (with the same options on used also for the hermes-tutorial) and buildHE.txt

Thank you very much once more.

Kind regards,
Tomas.
CMake.vars
buildHE.txt

Lukas Korous

unread,
Oct 18, 2013, 9:02:59 AM10/18/13
to herm...@googlegroups.com
Thanks,

I will take a look at hermes-examples then.

Lukas
Reply all
Reply to author
Forward
0 new messages