summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/truchas/package.py
blob: 80d51aa740fe2fb2e39336496c981395d93b37a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Truchas(CMakePackage):
    """Physics-based modeling and simulation of manufacturing processes.

    Truchas includes coupled physics models for incompressible multi-material
    flow with interface tracking, heat transfer, phase change, view factor
    thermal radiation, species advection-diffusion, elastic/plastic mechanics
    with contact, and electromagnetics. It employs finite volume, finite element,
    and mimetic finite difference discretizations on 3-D unstructured meshes
    composed of mixed cell types.
    """

    homepage = "https://www.truchas.org"
    url = "https://gitlab.com/truchas/truchas/-/archive/22.04.1/truchas-22.04.1.tar.bz2"
    git = "https://gitlab.com/truchas/truchas.git"

    maintainers("pbrady", "zjibben")

    version("develop", branch="master")
    version("23.06", sha256="a786caba5129d7e33ba42a06751d6c570bd3b9697e3404276a56216d27820c68")
    version("22.04.1", sha256="ed2000f27ee5c4bd3024063a374023878c61e8a3c76c37542fffd341d1226dc1")

    # ------------------------------------------------------------ #
    # Variants
    # ------------------------------------------------------------ #

    variant("portage", default=False, description="use the portage data mapping tool")
    variant("metis", default=True, description="use metis for grid partitioning")
    variant("std_name", default=False, description="enable std_mod_proc_name with intel")
    variant("config", default=True, description="use proved truchas config files for cmake")

    # ------------------------------------------------------------ #
    # Build dependencies
    # ------------------------------------------------------------ #
    depends_on("cmake@3.16:", type="build")

    # ------------------------------------------------------------ #
    # Test suite and restart utils
    # ------------------------------------------------------------ #
    depends_on("python@3.5:")
    depends_on("py-numpy@1.12:")
    depends_on("py-h5py")

    # ------------------------------------------------------------ #
    # IO dependencies
    # ------------------------------------------------------------ #
    depends_on("exodusii@2020-05-12: +mpi")
    depends_on("scorpio")
    depends_on("petaca@22.03: +shared")
    depends_on("petaca@22.03: +shared +std_name", when="+std_name")

    # ------------------------------------------------------------ #
    # Partitioning
    # ------------------------------------------------------------ #
    depends_on("chaco")
    depends_on("metis@5:", when="+metis")

    # ------------------------------------------------------------ #
    # Radiation
    # ------------------------------------------------------------ #
    depends_on("chaparral +mpi")

    # ------------------------------------------------------------ #
    # Solvers
    # ------------------------------------------------------------ #
    depends_on("hypre@2.20: ~fortran")
    depends_on("netlib-lapack")

    # ------------------------------------------------------------ #
    # Mapping
    # ------------------------------------------------------------ #
    depends_on("portage@3:", when="+portage")

    def cmake_args(self):
        # baseline config args
        opts = [
            self.define_from_variant("USE_METIS", "metis"),
            self.define_from_variant("USE_PORTAGE", "portage"),
            self.define_from_variant("ENABLE_STD_MOD_PROC_NAME", "std_name"),
        ]

        spec = self.spec
        if "+config" in spec:
            root = self.root_cmakelists_dir

            nag = "nag" in self.compiler.fc

            if spec.satisfies("platform=linux"):
                if nag or "%nag" in spec:
                    opts.append("-C {}/config/linux-nag.cmake".format(root))
                elif "%gcc" in spec:
                    opts.append("-C {}/config/linux-gcc.cmake".format(root))
                elif "%intel" in spec:
                    opts.append("-C {}/config/linux-intel.cmake".format(root))

            elif spec.satisfies("platform=darwin"):
                if nag or "%nag" in spec:
                    opts.append("-C {}/config/mac-nag.cmake".format(root))

            if self.spec.satisfies("%apple-clang@12:"):
                opts.append(
                    self.define("CMAKE_C_FLAGS", "-Wno-error=implicit-function-declaration")
                )

        return opts