https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CoefficientManager.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
12#pragma once
13
14#include <map>
15#include <string>
16#include <tuple>
17#include <utility>
18#include <variant>
19#include <vector>
20
21#include "MooseException.h"
22
23#include "CoefficientMap.h"
24
25namespace Moose::MFEM
26{
33{
34public:
35 CoefficientManager() = default;
36
40 mfem::Coefficient & declareScalar(const std::string & name,
41 const std::string & existing_or_literal);
43 template <class P, class... Args>
44 P & declareScalar(const std::string & name, Args &&... args)
45 {
46 auto coef = _scalar_coeffs.make<P>(args...);
47 this->declareScalar(name, coef);
48 return *coef;
49 }
50
58 mfem::Coefficient & declareScalarProperty(const std::string & name,
59 const std::vector<std::string> & blocks,
60 const std::string & existing_or_literal);
67 template <class P, class... Args>
68 mfem::Coefficient & declareScalarProperty(const std::string & name,
69 const std::vector<std::string> & blocks,
70 Args &&... args)
71 {
72 return this->declareScalarProperty(name, blocks, _scalar_coeffs.make<P>(args...));
73 }
74
78 mfem::VectorCoefficient & declareVector(const std::string & name,
79 const std::string & existing_or_literal);
81 template <class P, class... Args>
82 P & declareVector(const std::string & name, Args &&... args)
83 {
84 auto coef = _vector_coeffs.make<P>(args...);
85 this->declareVector(name, coef);
86 return *coef;
87 }
88
97 mfem::VectorCoefficient & declareVectorProperty(const std::string & name,
98 const std::vector<std::string> & blocks,
99 const std::string & existing_or_literal);
106 template <class P, class... Args>
107 mfem::VectorCoefficient & declareVectorProperty(const std::string & name,
108 const std::vector<std::string> & blocks,
109 Args &&... args)
110 {
111 return this->declareVectorProperty(name, blocks, _vector_coeffs.make<P>(args...));
112 }
113
118 mfem::MatrixCoefficient & declareMatrix(const std::string & name,
119 const std::string & existing_coef);
121 template <class P, class... Args>
122 P & declareMatrix(const std::string & name, Args &&... args)
123 {
124 auto coef = _matrix_coeffs.make<P>(args...);
125 this->declareMatrix(name, coef);
126 return *coef;
127 }
128
137 mfem::MatrixCoefficient & declareMatrixProperty(const std::string & name,
138 const std::vector<std::string> & blocks,
139 const std::string & existing_coef);
146 template <class P, class... Args>
147 mfem::MatrixCoefficient & declareMatrixProperty(const std::string & name,
148 const std::vector<std::string> & blocks,
149 Args &&... args)
150 {
151 return this->declareMatrixProperty(name, blocks, _matrix_coeffs.make<P>(args...));
152 }
153
157 mfem::Coefficient & getScalarCoefficient(const std::string & name);
158
162 mfem::VectorCoefficient & getVectorCoefficient(const std::string & name);
163
168 mfem::MatrixCoefficient & getMatrixCoefficient(const std::string & name);
169
170 bool scalarPropertyIsDefined(const std::string & name, const std::string & block) const;
171 bool vectorPropertyIsDefined(const std::string & name, const std::string & block) const;
172 bool matrixPropertyIsDefined(const std::string & name, const std::string & block) const;
173 void setTime(const mfem::real_t time);
174
178 void markSolutionChanged();
179
180private:
184
185 mfem::Coefficient & declareScalar(const std::string & name,
186 std::shared_ptr<mfem::Coefficient> coef);
187 mfem::Coefficient & declareScalarProperty(const std::string & name,
188 const std::vector<std::string> & blocks,
189 std::shared_ptr<mfem::Coefficient> coef);
190 mfem::VectorCoefficient & declareVector(const std::string & name,
191 std::shared_ptr<mfem::VectorCoefficient> coef);
192 mfem::VectorCoefficient & declareVectorProperty(const std::string & name,
193 const std::vector<std::string> & blocks,
194 std::shared_ptr<mfem::VectorCoefficient> coef);
195 mfem::MatrixCoefficient & declareMatrix(const std::string & name,
196 std::shared_ptr<mfem::MatrixCoefficient> coef);
197 mfem::MatrixCoefficient & declareMatrixProperty(const std::string & name,
198 const std::vector<std::string> & blocks,
199 std::shared_ptr<mfem::MatrixCoefficient> coef);
200 std::shared_ptr<mfem::Coefficient> getScalarCoefficientPtr(const std::string & name);
201 std::shared_ptr<mfem::VectorCoefficient> getVectorCoefficientPtr(const std::string & name);
202 std::shared_ptr<mfem::MatrixCoefficient> getMatrixCoefficientPtr(const std::string & name);
203};
204}
205
206#endif
char ** blocks
Front-end class for creating and storing MFEM coefficients.
std::shared_ptr< mfem::Coefficient > getScalarCoefficientPtr(const std::string &name)
mfem::MatrixCoefficient & declareMatrixProperty(const std::string &name, const std::vector< std::string > &blocks, Args &&... args)
Use a new matrix coefficient, constructed from the argument pack, for a property on some blocks of th...
mfem::VectorCoefficient & declareVectorProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_or_literal)
Use an existing vector coefficient for a property on some blocks of the mesh.
mfem::VectorCoefficient & declareVectorProperty(const std::string &name, const std::vector< std::string > &blocks, Args &&... args)
Use a new vector coefficient, constructed from the argument pack, for a property on some blocks of th...
bool scalarPropertyIsDefined(const std::string &name, const std::string &block) const
std::shared_ptr< mfem::VectorCoefficient > getVectorCoefficientPtr(const std::string &name)
mfem::Coefficient & declareScalarProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_or_literal)
Use an existing scalar coefficient for a property on some blocks of the mesh.
void setTime(const mfem::real_t time)
P & declareVector(const std::string &name, Args &&... args)
Create a new vector coefficient, constructed from the argument pack.
mfem::Coefficient & declareScalar(const std::string &name, const std::string &existing_or_literal)
Declare an alias to an existing scalar coefficient or, if it does not exist, try interpreting the nam...
mfem::MatrixCoefficient & declareMatrixProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_coef)
Use an existing matrix coefficient for a property on some blocks of the mesh.
mfem::MatrixCoefficient & declareMatrix(const std::string &name, const std::string &existing_coef)
Declare an alias to an existing matrix coefficient.
P & declareMatrix(const std::string &name, Args &&... args)
Create a new matrix coefficient, constructed from the argument pack.
mfem::MatrixCoefficient & getMatrixCoefficient(const std::string &name)
Return scalar coefficient with the given name.
mfem::VectorCoefficient & getVectorCoefficient(const std::string &name)
Return a vector coefficient with the given name or, if that doesn't exists, try interpreting the name...
bool vectorPropertyIsDefined(const std::string &name, const std::string &block) const
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Return a scalar coefficient with the given name or, if that doesn't exists, try interpreting the name...
void markSolutionChanged()
Notify quadrature function coefficients that solution variables have changed, marking the stored valu...
mfem::VectorCoefficient & declareVector(const std::string &name, const std::string &existing_or_literal)
Declare an alias to an existing vector coefficientor or, if it does not exist, try interpreting the n...
std::shared_ptr< mfem::MatrixCoefficient > getMatrixCoefficientPtr(const std::string &name)
bool matrixPropertyIsDefined(const std::string &name, const std::string &block) const
P & declareScalar(const std::string &name, Args &&... args)
Create a new scalar coefficient, constructed from the argument pack.
mfem::Coefficient & declareScalarProperty(const std::string &name, const std::vector< std::string > &blocks, Args &&... args)
Use a new scalar coefficient, constructed from the argument pack, for a property on some blocks of th...
std::shared_ptr< P > make(Args &&... args)
Make arbitrary coefficients which will be tracked by this object.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).