21template<
typename ValueType>
24 LaplacianOperatorFactory<ValueType>,
25 Parameters<const Executor&, const UnstructuredMesh&, const Input&>>
30 static std::unique_ptr<LaplacianOperatorFactory<ValueType>>
33 std::string key = (std::holds_alternative<Dictionary>(inputs))
34 ? std::get<Dictionary>(inputs).get<std::string>(
"LaplacianOperator")
35 : std::get<TokenList>(inputs).next<std::string>();
40 static std::string
name() {
return "LaplacianOperatorFactory"; }
71 virtual std::unique_ptr<LaplacianOperatorFactory<ValueType>>
clone()
const = 0;
80template<
typename ValueType>
94 laplacianOperatorStrategy_(
95 lapOp.laplacianOperatorStrategy_ ? lapOp.laplacianOperatorStrategy_->clone() : nullptr
106 laplacianOperatorStrategy_(
117 gamma_(gamma), laplacianOperatorStrategy_(std::move(laplacianOperatorStrategy)) {};
123 gamma_(gamma), laplacianOperatorStrategy_(nullptr) {};
128 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
131 laplacianOperatorStrategy_->laplacian(tmpsource, gamma_, this->
field_, operatorScaling);
137 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
138 return laplacianOperatorStrategy_->createEmptyLinearSystem();
143 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
145 laplacianOperatorStrategy_->laplacian(ls, gamma_, this->
field_, operatorScaling);
161 laplacianOperatorStrategy_->laplacian(lapPhi, gamma_, this->
getField(), operatorScaling);
168 if (std::holds_alternative<NeoFOAM::Dictionary>(input))
170 auto dict = std::get<NeoFOAM::Dictionary>(input);
171 std::string schemeName =
"laplacian(" + gamma_.
name +
"," + this->
field_.name +
")";
173 laplacianOperatorStrategy_ =
178 auto tokens = std::get<NeoFOAM::TokenList>(input);
179 laplacianOperatorStrategy_ =
184 std::string
getName()
const {
return "LaplacianOperator"; }
190 std::unique_ptr<LaplacianOperatorFactory<ValueType>> laplacianOperatorStrategy_;
A class to contain the data and executors for a field and define some basic operations.
size_t size() const
Gets the size of the field.
const Executor & exec() const
Gets the executor associated with the field.
A factory class for runtime selection of derived classes.
A class representing a list of tokens.
Represents an unstructured mesh in NeoFOAM.
A class that represents a coefficient for the NeoFOAM dsl.
OperatorMixin(const Executor exec, const Coeff &coeffs, VolumeField< ValueType > &field, Operator::Type type)
virtual const Executor & exec() const final
VolumeField< ValueType > & getField()
const Executor exec_
Executor associated with the field. (CPU, GPU, openMP, etc.)
VolumeField< ValueType > & field_
virtual void laplacian(la::LinearSystem< ValueType, localIdx > &ls, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
LaplacianOperatorFactory(const Executor &exec, const UnstructuredMesh &mesh)
virtual la::LinearSystem< ValueType, localIdx > createEmptyLinearSystem() const =0
virtual std::unique_ptr< LaplacianOperatorFactory< ValueType > > clone() const =0
virtual ~LaplacianOperatorFactory()
virtual void laplacian(VolumeField< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
static std::string name()
const UnstructuredMesh & mesh_
virtual void laplacian(Field< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
static std::unique_ptr< LaplacianOperatorFactory< ValueType > > create(const Executor &exec, const UnstructuredMesh &uMesh, const Input &inputs)
std::string getName() const
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, std::unique_ptr< LaplacianOperatorFactory< ValueType > > laplacianOperatorStrategy)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, Input input)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi)
LaplacianOperator(const LaplacianOperator &lapOp)
la::LinearSystem< ValueType, localIdx > createEmptyLinearSystem() const
void explicitOperation(Field< ValueType > &source)
void implicitOperation(la::LinearSystem< ValueType, localIdx > &ls)
void build(const Input &input)
void laplacian(VolumeField< scalar > &lapPhi)
Represents a surface field in a finite volume method.
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
std::variant< Dictionary, TokenList > Input
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor