svMultiPhysics
Loading...
Searching...
No Matches
all_fun.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef ALL_FUN_H
5#define ALL_FUN_H
6
7#include "Array3.h"
8#include "SolutionStates.h"
9#include "Array.h"
10#include "Vector.h"
11#include "ComMod.h"
12
13#include "consts.h"
14
15#include <optional>
16#include <string>
17
18namespace all_fun {
19
20 double aspect_ratio(ComMod& com_mod, const int nDim, const int eNoN, const Array<double>& x);
21
22 void commu(const ComMod& com_mod, Vector<double>& u);
23 void commu(const ComMod& com_mod, Array<double>& u);
24
25 int domain(const ComMod& com_mod, const mshType& lM, const int iEq, const int e);
26
27 void find_face(const std::vector<mshType>& mesh_list, const std::string& faceName, int& iM, int& iFa);
28
29 void find_msh(const std::vector<mshType>& mesh_list, const std::string& mesh_name, int& iM);
30
31 Array<double> global(const ComMod& com_mod, const CmMod& cm_mod, const mshType& lM, const Array<double>& U);
32
33 double integ(const ComMod& com_mod, const CmMod& cm_mod, int iM, const Array<double>& s, const SolutionStates& solutions);
34
35 double integ(const ComMod& com_mod, const CmMod& cm_mod, int dId, const Array<double>& s, int l, int u,
36 const SolutionStates& solutions, bool pFlag=false);
37
38 /**
39 * @brief Integrate a scalar field over a boundary face.
40 *
41 * Reproduces 'FUNCTION IntegS(lFa, s, pflag)'. The scalar field s is
42 * integrated over the face, i.e. this computes
43 * \f[
44 * \int_{\Gamma} s \, d\Gamma,
45 * \f]
46 * where \f$\Gamma\f$ is the boundary face.
47 *
48 * For simulations involving structural displacement, this function allows
49 * computing the integral in any of the following configurations:
50 * - reference configuration (the mesh is not displaced);
51 * - current configuration (the mesh is displaced by the current displacement
52 * field);
53 * - old configuration (the mesh is displaced by the displacement field from
54 * previous time step).
55 *
56 * @param[in] com_mod The common module.
57 * @param[in] cm_mod The communication module containing MPI data.
58 * @param[in] lFa The boundary face over which the integral is computed.
59 * @param[in] s The scalar value at each node of the mesh.
60 * @param[in] solutions The solution states that the displacement fields are
61 * extracted from.
62 * @param[in] pFlag Whether to use the Taylor-Hood function space for the
63 * pressure field.
64 * @param[in] cfg The configuration in which the integral is computed
65 * (reference, old or current).
66 * @param[in] displacement_index The index of the displacement field in the
67 * solution arrays. This should correspond to the start index of the
68 * equation that solves for the displacement.
69 */
70 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
71 const Vector<double> &s, const SolutionStates &solutions,
72 bool pFlag, consts::MechanicalConfigurationType cfg,
73 const unsigned int displacement_index);
74
75 /**
76 * @brief Integrate a scalar field over a boundary face.
77 *
78 * This is the overload to use in the general case. The other overload adds
79 * the ability to integrate over a displaced configuration, which is only
80 * relevant for simulations involving structural displacement. See it for the
81 * meaning of the arguments.
82 */
83 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
84 const Vector<double> &s, const SolutionStates &solutions,
85 bool pFlag);
86
87 /**
88 * @brief Integrate one or more components of a field over a boundary face.
89 *
90 * Reproduces 'FUNCTION IntegG(lFa, s, l, u, THflag)'. Rows l to u of s are
91 * integrated over the face. When they span the spatial dimensions the field
92 * is dotted with the outward surface normal (i.e. a flux is computed),
93 * \f[
94 * \int_{\Gamma} \sum_{i=l}^{u} s_i \, n_i \, d\Gamma,
95 * \f]
96 * otherwise the single row l is integrated as a scalar,
97 * \f[
98 * \int_{\Gamma} s_l \, d\Gamma,
99 * \f]
100 * where \f$\Gamma\f$ is the boundary face and \f$\mathbf{n}\f$ its outward
101 * unit normal.
102 *
103 * For simulations involving structural displacement, this function allows
104 * computing the integral in any of the following configurations:
105 * - reference configuration (the mesh is not displaced);
106 * - current configuration (the mesh is displaced by the current displacement
107 * field);
108 * - old configuration (the mesh is displaced by the displacement field from
109 * previous time step).
110 *
111 * @param[in] com_mod The common module.
112 * @param[in] cm_mod The communication module containing MPI data.
113 * @param[in] lFa The boundary face over which the integral is computed.
114 * @param[in] s The field value at each node of the mesh.
115 * @param[in] l The first row of s to integrate.
116 * @param[in] solutions The solution states that the displacement fields are
117 * extracted from.
118 * @param[in] uo The last row of s to integrate. Defaults to l, i.e. a single
119 * component.
120 * @param[in] THflag Whether to use the Taylor-Hood function space for the
121 * pressure field.
122 * @param[in] cfg The configuration in which the integral is computed
123 * (reference, old or current).
124 * @param[in] displacement_index The index of the displacement field in the
125 * solution arrays. This should correspond to the start index of the
126 * equation that solves for the displacement.
127 */
128 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
129 const Array<double> &s, const int l,
130 const SolutionStates &solutions, std::optional<int> uo,
131 bool THflag, consts::MechanicalConfigurationType cfg,
132 const unsigned int displacement_index);
133
134 /**
135 * @brief Integrate one or more components of a field over a boundary face.
136 *
137 * This is the overload to use in the general case. The other overload adds
138 * the ability to integrate over a displaced configuration, which is only
139 * relevant for simulations involving structural displacement. See it for the
140 * meaning of the arguments.
141 */
142 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
143 const Array<double> &s, const int l,
144 const SolutionStates &solutions, std::optional<int> uo,
145 bool THflag);
146
147 /**
148 * @brief Integrate the flux of a vector field over a boundary face.
149 *
150 * Reproduces 'FUNCTION IntegV(lFa, s)'. The vector field s (one component per
151 * spatial dimension at each node) is dotted with the outward surface normal
152 * and integrated over the face, i.e. this computes
153 * \f[
154 * \int_{\Gamma} \mathbf{s} \cdot \mathbf{n} \, d\Gamma,
155 * \f]
156 * where \f$\Gamma\f$ is the boundary face and \f$\mathbf{n}\f$ its outward
157 * unit normal.
158 *
159 * For simulations involving structural displacement, this function allows
160 * computing the integral in any of the following configurations:
161 * - reference configuration (the mesh is not displaced);
162 * - current configuration (the mesh is displaced by the current displacement
163 * field);
164 * - old configuration (the mesh is displaced by the displacement field from
165 * previous time step).
166 *
167 * @param[in] com_mod The common module.
168 * @param[in] cm_mod The communication module containing MPI data.
169 * @param[in] lFa The boundary face over which the integral is computed.
170 * @param[in] s The vector value at each node of the mesh.
171 * @param[in] solutions The solution states that the displacement fields are
172 * extracted from.
173 * @param[in] cfg The configuration in which the integral is computed
174 * (reference, old or current).
175 * @param[in] displacement_index The index of the displacement field in the
176 * solution arrays. This should correspond to the start index of the
177 * equation that solves for the displacement.
178 */
179 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
180 const Array<double> &s, const SolutionStates &solutions,
181 consts::MechanicalConfigurationType cfg,
182 const unsigned int displacement_index);
183
184 /**
185 * @brief Integrate the flux of a vector field over a boundary face.
186 *
187 * This is the overload to use in the general case. The other overload adds
188 * the ability to integrate over a displaced configuration, which is only
189 * relevant for simulations involving structural displacement. See it for the
190 * meaning of the arguments.
191 */
192 double integ(const ComMod &com_mod, const CmMod &cm_mod, const faceType &lFa,
193 const Array<double> &s, const SolutionStates &solutions);
194
195 bool is_domain(const ComMod& com_mod, const eqType& eq, const int node, const consts::EquationType phys);
196
197 double jacobian(ComMod& com_mod, const int nDim, const int eNoN, const Array<double>& x, const Array<double>&Nxi);
198
199 Vector<int> local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Vector<int>& u);
200
201 Array<double> local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array<double>& u);
202
203 Array3<double> local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array3<double>& u);
204
205 Vector<double> mkc(const ComMod& com_mod, Vector<double>& U);
206 Array<double> mkc(const ComMod& com_mod, Array<double>& U);
207
208 void mkci(const ComMod& com_mod, Vector<double>& U);
209 void mkci(const ComMod& com_mod, Array<double>& U);
210
211 void set_dmn_id(mshType& mesh, const int iDmn, const int ifirst=consts::int_inf, const int ilast=consts::int_inf);
212
213 double skewness(ComMod& com_mod, const int nDim, const int eNoN, const Array<double>& x);
214
215 void split_jobs(int tid, int m, int n, Array<double>& A, Vector<double>& b);
216
217 /// @brief This routine is for calculating values by the inverse of general BC
218 //
219 void igbc(const ComMod &com_mod, const MBType &gm, Array<double> &Y,
220 Array<double> &dY);
221};
222
223#endif
224
The Array3 template class implements a simple interface to 3D arrays.
Definition Array3.h:25
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:36
The ComMod class duplicates the data structures in the Fortran COMMOD module defined in MOD....
Definition ComMod.h:1597
Moving boundary data structure (used for general BC)
Definition ComMod.h:51
The Vector template class is used for storing int and double data.
Definition Vector.h:26
The cmType class stores data and defines methods used for mpi communication.
Definition CmMod.h:56
Equation type.
Definition ComMod.h:1084
The face type containing mesh at boundary.
Definition ComMod.h:469
This is the container for a mesh or NURBS patch, those specific to NURBS are noted.
Definition ComMod.h:878
Holds solution state at old, current, and intermediate time levels.
Definition SolutionStates.h:39